package gui;

import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.geometry.Insets;
import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.TableView;
import javafx.scene.control.TabPane;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.stage.Modality;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableColumn.CellDataFeatures;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.control.TitledPane;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeView;
import javafx.scene.control.Tooltip;

import javafx.scene.layout.GridPane;
import javafx.scene.layout.Region;
import javafx.scene.layout.VBox;
import javafx.stage.FileChooser;
import javafx.stage.FileChooser.ExtensionFilter;
import javafx.stage.Stage;
import java.io.File;
import javafx.scene.control.cell.PropertyValueFactory;
import java.util.List;
import java.time.LocalDate;
import java.util.LinkedList;

import java.lang.reflect.Array;
import java.net.URL;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.ResourceBundle;

import gui.supportclass.*;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.beans.property.ReadOnlyStringWrapper;
import javafx.beans.value.ObservableValue;
import javafx.util.Callback;
import services.*;
import services.impl.*;
import java.time.format.DateTimeFormatter;
import java.lang.reflect.Method;

import entities.*;

public class PrototypeController implements Initializable {


	DateTimeFormatter dateformatter;
	 
	@Override
	public void initialize(URL location, ResourceBundle resources) {
	
		newbikesharingsystemsystem_service = ServiceManager.createNewBikeSharingSystemSystem();
		thirdpartyservices_service = ServiceManager.createThirdPartyServices();
		registeraccountservice_service = ServiceManager.createRegisterAccountService();
		unlockvehicleservice_service = ServiceManager.createUnlockVehicleService();
		trackridingcostsservice_service = ServiceManager.createTrackRidingCostsService();
		processmaintenancerequestsservice_service = ServiceManager.createProcessMaintenanceRequestsService();
				
		this.dateformatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
		
	   	 //prepare data for contract
	   	 prepareData();
	   	 
	   	 //generate invariant panel
	   	 genereateInvairantPanel();
	   	 
		 //Actor Threeview Binding
		 actorTreeViewBinding();
		 
		 //Generate
		 generatOperationPane();
		 genereateOpInvariantPanel();
		 
		 //prilimariry data
		 try {
			DataFitService.fit();
		 } catch (PreconditionException e) {
			// TODO Auto-generated catch block
		 	e.printStackTrace();
		 }
		 
		 //generate class statistic
		 classStatisicBingding();
		 
		 //generate object statistic
		 generateObjectTable();
		 
		 //genereate association statistic
		 associationStatisicBingding();

		 //set listener 
		 setListeners();
	}
	
	/**
	 * deepCopyforTreeItem (Actor Generation)
	 */
	TreeItem<String> deepCopyTree(TreeItem<String> item) {
		    TreeItem<String> copy = new TreeItem<String>(item.getValue());
		    for (TreeItem<String> child : item.getChildren()) {
		        copy.getChildren().add(deepCopyTree(child));
		    }
		    return copy;
	}
	
	/**
	 * check all invariant and update invariant panel
	 */
	public void invairantPanelUpdate() {
		
		try {
			
			for (Entry<String, Label> inv : entity_invariants_label_map.entrySet()) {
				String invname = inv.getKey();
				String[] invt = invname.split("_");
				String entityName = invt[0];
				for (Object o : EntityManager.getAllInstancesOf(entityName)) {				
					 Method m = o.getClass().getMethod(invname);
					 if ((boolean)m.invoke(o) == false) {
						 inv.getValue().setStyle("-fx-max-width: Infinity;" + 
									"-fx-background-color: linear-gradient(to right, #7FFF00 0%, #af0c27 100%);" +
								    "-fx-padding: 6px;" +
								    "-fx-border-color: black;");
						 break;
					 }
				}				
			}
			
			for (Entry<String, Label> inv : service_invariants_label_map.entrySet()) {
				String invname = inv.getKey();
				String[] invt = invname.split("_");
				String serviceName = invt[0];
				for (Object o : ServiceManager.getAllInstancesOf(serviceName)) {				
					 Method m = o.getClass().getMethod(invname);
					 if ((boolean)m.invoke(o) == false) {
						 inv.getValue().setStyle("-fx-max-width: Infinity;" + 
									"-fx-background-color: linear-gradient(to right, #7FFF00 0%, #af0c27 100%);" +
								    "-fx-padding: 6px;" +
								    "-fx-border-color: black;");
						 break;
					 }
				}
			}
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}	

	/**
	 * check op invariant and update op invariant panel
	 */		
	public void opInvairantPanelUpdate() {
		
		try {
			
			for (Entry<String, Label> inv : op_entity_invariants_label_map.entrySet()) {
				String invname = inv.getKey();
				String[] invt = invname.split("_");
				String entityName = invt[0];
				for (Object o : EntityManager.getAllInstancesOf(entityName)) {
					 Method m = o.getClass().getMethod(invname);
					 if ((boolean)m.invoke(o) == false) {
						 inv.getValue().setStyle("-fx-max-width: Infinity;" + 
									"-fx-background-color: linear-gradient(to right, #7FFF00 0%, #af0c27 100%);" +
								    "-fx-padding: 6px;" +
								    "-fx-border-color: black;");
						 break;
					 }
				}
			}
			
			for (Entry<String, Label> inv : op_service_invariants_label_map.entrySet()) {
				String invname = inv.getKey();
				String[] invt = invname.split("_");
				String serviceName = invt[0];
				for (Object o : ServiceManager.getAllInstancesOf(serviceName)) {
					 Method m = o.getClass().getMethod(invname);
					 if ((boolean)m.invoke(o) == false) {
						 inv.getValue().setStyle("-fx-max-width: Infinity;" + 
									"-fx-background-color: linear-gradient(to right, #7FFF00 0%, #af0c27 100%);" +
								    "-fx-padding: 6px;" +
								    "-fx-border-color: black;");
						 break;
					 }
				}
			}
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	/* 
	*	generate op invariant panel 
	*/
	public void genereateOpInvariantPanel() {
		
		opInvariantPanel = new HashMap<String, VBox>();
		op_entity_invariants_label_map = new LinkedHashMap<String, Label>();
		op_service_invariants_label_map = new LinkedHashMap<String, Label>();
		
		VBox v;
		List<String> entities;
		v = new VBox();
		
		//entities invariants
		entities = RegisterAccountServiceImpl.opINVRelatedEntity.get("checkPhoneValidity");
		if (entities != null) {
			for (String opRelatedEntities : entities) {
				for (Entry<String, String> inv : entity_invariants_map.entrySet()) {
					
					String invname = inv.getKey();
					String[] invt = invname.split("_");
					String entityName = invt[0];
		
					if (opRelatedEntities.equals(entityName)) {
						Label l = new Label(invname);
						l.setStyle("-fx-max-width: Infinity;" + 
								"-fx-background-color: linear-gradient(to right, #7FFF00 0%, #F0FFFF 100%);" +
							    "-fx-padding: 6px;" +
							    "-fx-border-color: black;");
						Tooltip tp = new Tooltip();
						tp.setText(inv.getValue());
						l.setTooltip(tp);
						
						op_entity_invariants_label_map.put(invname, l);
						
						v.getChildren().add(l);
					}
				}
			}
		} else {
			Label l = new Label("checkPhoneValidity" + " is no related invariants");
			l.setPadding(new Insets(8, 8, 8, 8));
			v.getChildren().add(l);
		}
		
		//service invariants
		for (Entry<String, String> inv : service_invariants_map.entrySet()) {
			
			String invname = inv.getKey();
			String[] invt = invname.split("_");
			String serviceName = invt[0];
			
			if (serviceName.equals("RegisterAccountService")) {
				Label l = new Label(invname);
				l.setStyle("-fx-max-width: Infinity;" + 
						   "-fx-background-color: linear-gradient(to right, #7FFF00 0%, #F0FFFF 100%);" +
						   "-fx-padding: 6px;" +
						   "-fx-border-color: black;");
				Tooltip tp = new Tooltip();
				tp.setText(inv.getValue());
				l.setTooltip(tp);
				
				op_entity_invariants_label_map.put(invname, l);
				
				v.getChildren().add(l);
			}
		}
		opInvariantPanel.put("checkPhoneValidity", v);
		
		v = new VBox();
		
		//entities invariants
		entities = RegisterAccountServiceImpl.opINVRelatedEntity.get("createAccount");
		if (entities != null) {
			for (String opRelatedEntities : entities) {
				for (Entry<String, String> inv : entity_invariants_map.entrySet()) {
					
					String invname = inv.getKey();
					String[] invt = invname.split("_");
					String entityName = invt[0];
		
					if (opRelatedEntities.equals(entityName)) {
						Label l = new Label(invname);
						l.setStyle("-fx-max-width: Infinity;" + 
								"-fx-background-color: linear-gradient(to right, #7FFF00 0%, #F0FFFF 100%);" +
							    "-fx-padding: 6px;" +
							    "-fx-border-color: black;");
						Tooltip tp = new Tooltip();
						tp.setText(inv.getValue());
						l.setTooltip(tp);
						
						op_entity_invariants_label_map.put(invname, l);
						
						v.getChildren().add(l);
					}
				}
			}
		} else {
			Label l = new Label("createAccount" + " is no related invariants");
			l.setPadding(new Insets(8, 8, 8, 8));
			v.getChildren().add(l);
		}
		
		//service invariants
		for (Entry<String, String> inv : service_invariants_map.entrySet()) {
			
			String invname = inv.getKey();
			String[] invt = invname.split("_");
			String serviceName = invt[0];
			
			if (serviceName.equals("RegisterAccountService")) {
				Label l = new Label(invname);
				l.setStyle("-fx-max-width: Infinity;" + 
						   "-fx-background-color: linear-gradient(to right, #7FFF00 0%, #F0FFFF 100%);" +
						   "-fx-padding: 6px;" +
						   "-fx-border-color: black;");
				Tooltip tp = new Tooltip();
				tp.setText(inv.getValue());
				l.setTooltip(tp);
				
				op_entity_invariants_label_map.put(invname, l);
				
				v.getChildren().add(l);
			}
		}
		opInvariantPanel.put("createAccount", v);
		
		v = new VBox();
		
		//entities invariants
		entities = RegisterAccountServiceImpl.opINVRelatedEntity.get("issueNewcomerCoupons");
		if (entities != null) {
			for (String opRelatedEntities : entities) {
				for (Entry<String, String> inv : entity_invariants_map.entrySet()) {
					
					String invname = inv.getKey();
					String[] invt = invname.split("_");
					String entityName = invt[0];
		
					if (opRelatedEntities.equals(entityName)) {
						Label l = new Label(invname);
						l.setStyle("-fx-max-width: Infinity;" + 
								"-fx-background-color: linear-gradient(to right, #7FFF00 0%, #F0FFFF 100%);" +
							    "-fx-padding: 6px;" +
							    "-fx-border-color: black;");
						Tooltip tp = new Tooltip();
						tp.setText(inv.getValue());
						l.setTooltip(tp);
						
						op_entity_invariants_label_map.put(invname, l);
						
						v.getChildren().add(l);
					}
				}
			}
		} else {
			Label l = new Label("issueNewcomerCoupons" + " is no related invariants");
			l.setPadding(new Insets(8, 8, 8, 8));
			v.getChildren().add(l);
		}
		
		//service invariants
		for (Entry<String, String> inv : service_invariants_map.entrySet()) {
			
			String invname = inv.getKey();
			String[] invt = invname.split("_");
			String serviceName = invt[0];
			
			if (serviceName.equals("RegisterAccountService")) {
				Label l = new Label(invname);
				l.setStyle("-fx-max-width: Infinity;" + 
						   "-fx-background-color: linear-gradient(to right, #7FFF00 0%, #F0FFFF 100%);" +
						   "-fx-padding: 6px;" +
						   "-fx-border-color: black;");
				Tooltip tp = new Tooltip();
				tp.setText(inv.getValue());
				l.setTooltip(tp);
				
				op_entity_invariants_label_map.put(invname, l);
				
				v.getChildren().add(l);
			}
		}
		opInvariantPanel.put("issueNewcomerCoupons", v);
		
		v = new VBox();
		
		//entities invariants
		entities = UnlockVehicleServiceImpl.opINVRelatedEntity.get("establishBluetoothConnection");
		if (entities != null) {
			for (String opRelatedEntities : entities) {
				for (Entry<String, String> inv : entity_invariants_map.entrySet()) {
					
					String invname = inv.getKey();
					String[] invt = invname.split("_");
					String entityName = invt[0];
		
					if (opRelatedEntities.equals(entityName)) {
						Label l = new Label(invname);
						l.setStyle("-fx-max-width: Infinity;" + 
								"-fx-background-color: linear-gradient(to right, #7FFF00 0%, #F0FFFF 100%);" +
							    "-fx-padding: 6px;" +
							    "-fx-border-color: black;");
						Tooltip tp = new Tooltip();
						tp.setText(inv.getValue());
						l.setTooltip(tp);
						
						op_entity_invariants_label_map.put(invname, l);
						
						v.getChildren().add(l);
					}
				}
			}
		} else {
			Label l = new Label("establishBluetoothConnection" + " is no related invariants");
			l.setPadding(new Insets(8, 8, 8, 8));
			v.getChildren().add(l);
		}
		
		//service invariants
		for (Entry<String, String> inv : service_invariants_map.entrySet()) {
			
			String invname = inv.getKey();
			String[] invt = invname.split("_");
			String serviceName = invt[0];
			
			if (serviceName.equals("UnlockVehicleService")) {
				Label l = new Label(invname);
				l.setStyle("-fx-max-width: Infinity;" + 
						   "-fx-background-color: linear-gradient(to right, #7FFF00 0%, #F0FFFF 100%);" +
						   "-fx-padding: 6px;" +
						   "-fx-border-color: black;");
				Tooltip tp = new Tooltip();
				tp.setText(inv.getValue());
				l.setTooltip(tp);
				
				op_entity_invariants_label_map.put(invname, l);
				
				v.getChildren().add(l);
			}
		}
		opInvariantPanel.put("establishBluetoothConnection", v);
		
		v = new VBox();
		
		//entities invariants
		entities = UnlockVehicleServiceImpl.opINVRelatedEntity.get("sendUnlockCommand");
		if (entities != null) {
			for (String opRelatedEntities : entities) {
				for (Entry<String, String> inv : entity_invariants_map.entrySet()) {
					
					String invname = inv.getKey();
					String[] invt = invname.split("_");
					String entityName = invt[0];
		
					if (opRelatedEntities.equals(entityName)) {
						Label l = new Label(invname);
						l.setStyle("-fx-max-width: Infinity;" + 
								"-fx-background-color: linear-gradient(to right, #7FFF00 0%, #F0FFFF 100%);" +
							    "-fx-padding: 6px;" +
							    "-fx-border-color: black;");
						Tooltip tp = new Tooltip();
						tp.setText(inv.getValue());
						l.setTooltip(tp);
						
						op_entity_invariants_label_map.put(invname, l);
						
						v.getChildren().add(l);
					}
				}
			}
		} else {
			Label l = new Label("sendUnlockCommand" + " is no related invariants");
			l.setPadding(new Insets(8, 8, 8, 8));
			v.getChildren().add(l);
		}
		
		//service invariants
		for (Entry<String, String> inv : service_invariants_map.entrySet()) {
			
			String invname = inv.getKey();
			String[] invt = invname.split("_");
			String serviceName = invt[0];
			
			if (serviceName.equals("UnlockVehicleService")) {
				Label l = new Label(invname);
				l.setStyle("-fx-max-width: Infinity;" + 
						   "-fx-background-color: linear-gradient(to right, #7FFF00 0%, #F0FFFF 100%);" +
						   "-fx-padding: 6px;" +
						   "-fx-border-color: black;");
				Tooltip tp = new Tooltip();
				tp.setText(inv.getValue());
				l.setTooltip(tp);
				
				op_entity_invariants_label_map.put(invname, l);
				
				v.getChildren().add(l);
			}
		}
		opInvariantPanel.put("sendUnlockCommand", v);
		
		v = new VBox();
		
		//entities invariants
		entities = UnlockVehicleServiceImpl.opINVRelatedEntity.get("playUnlockSuccessVoice");
		if (entities != null) {
			for (String opRelatedEntities : entities) {
				for (Entry<String, String> inv : entity_invariants_map.entrySet()) {
					
					String invname = inv.getKey();
					String[] invt = invname.split("_");
					String entityName = invt[0];
		
					if (opRelatedEntities.equals(entityName)) {
						Label l = new Label(invname);
						l.setStyle("-fx-max-width: Infinity;" + 
								"-fx-background-color: linear-gradient(to right, #7FFF00 0%, #F0FFFF 100%);" +
							    "-fx-padding: 6px;" +
							    "-fx-border-color: black;");
						Tooltip tp = new Tooltip();
						tp.setText(inv.getValue());
						l.setTooltip(tp);
						
						op_entity_invariants_label_map.put(invname, l);
						
						v.getChildren().add(l);
					}
				}
			}
		} else {
			Label l = new Label("playUnlockSuccessVoice" + " is no related invariants");
			l.setPadding(new Insets(8, 8, 8, 8));
			v.getChildren().add(l);
		}
		
		//service invariants
		for (Entry<String, String> inv : service_invariants_map.entrySet()) {
			
			String invname = inv.getKey();
			String[] invt = invname.split("_");
			String serviceName = invt[0];
			
			if (serviceName.equals("UnlockVehicleService")) {
				Label l = new Label(invname);
				l.setStyle("-fx-max-width: Infinity;" + 
						   "-fx-background-color: linear-gradient(to right, #7FFF00 0%, #F0FFFF 100%);" +
						   "-fx-padding: 6px;" +
						   "-fx-border-color: black;");
				Tooltip tp = new Tooltip();
				tp.setText(inv.getValue());
				l.setTooltip(tp);
				
				op_entity_invariants_label_map.put(invname, l);
				
				v.getChildren().add(l);
			}
		}
		opInvariantPanel.put("playUnlockSuccessVoice", v);
		
		v = new VBox();
		
		//entities invariants
		entities = TrackRidingCostsServiceImpl.opINVRelatedEntity.get("calculateFare");
		if (entities != null) {
			for (String opRelatedEntities : entities) {
				for (Entry<String, String> inv : entity_invariants_map.entrySet()) {
					
					String invname = inv.getKey();
					String[] invt = invname.split("_");
					String entityName = invt[0];
		
					if (opRelatedEntities.equals(entityName)) {
						Label l = new Label(invname);
						l.setStyle("-fx-max-width: Infinity;" + 
								"-fx-background-color: linear-gradient(to right, #7FFF00 0%, #F0FFFF 100%);" +
							    "-fx-padding: 6px;" +
							    "-fx-border-color: black;");
						Tooltip tp = new Tooltip();
						tp.setText(inv.getValue());
						l.setTooltip(tp);
						
						op_entity_invariants_label_map.put(invname, l);
						
						v.getChildren().add(l);
					}
				}
			}
		} else {
			Label l = new Label("calculateFare" + " is no related invariants");
			l.setPadding(new Insets(8, 8, 8, 8));
			v.getChildren().add(l);
		}
		
		//service invariants
		for (Entry<String, String> inv : service_invariants_map.entrySet()) {
			
			String invname = inv.getKey();
			String[] invt = invname.split("_");
			String serviceName = invt[0];
			
			if (serviceName.equals("TrackRidingCostsService")) {
				Label l = new Label(invname);
				l.setStyle("-fx-max-width: Infinity;" + 
						   "-fx-background-color: linear-gradient(to right, #7FFF00 0%, #F0FFFF 100%);" +
						   "-fx-padding: 6px;" +
						   "-fx-border-color: black;");
				Tooltip tp = new Tooltip();
				tp.setText(inv.getValue());
				l.setTooltip(tp);
				
				op_entity_invariants_label_map.put(invname, l);
				
				v.getChildren().add(l);
			}
		}
		opInvariantPanel.put("calculateFare", v);
		
		v = new VBox();
		
		//entities invariants
		entities = TrackRidingCostsServiceImpl.opINVRelatedEntity.get("updateFareSuspensionWindow");
		if (entities != null) {
			for (String opRelatedEntities : entities) {
				for (Entry<String, String> inv : entity_invariants_map.entrySet()) {
					
					String invname = inv.getKey();
					String[] invt = invname.split("_");
					String entityName = invt[0];
		
					if (opRelatedEntities.equals(entityName)) {
						Label l = new Label(invname);
						l.setStyle("-fx-max-width: Infinity;" + 
								"-fx-background-color: linear-gradient(to right, #7FFF00 0%, #F0FFFF 100%);" +
							    "-fx-padding: 6px;" +
							    "-fx-border-color: black;");
						Tooltip tp = new Tooltip();
						tp.setText(inv.getValue());
						l.setTooltip(tp);
						
						op_entity_invariants_label_map.put(invname, l);
						
						v.getChildren().add(l);
					}
				}
			}
		} else {
			Label l = new Label("updateFareSuspensionWindow" + " is no related invariants");
			l.setPadding(new Insets(8, 8, 8, 8));
			v.getChildren().add(l);
		}
		
		//service invariants
		for (Entry<String, String> inv : service_invariants_map.entrySet()) {
			
			String invname = inv.getKey();
			String[] invt = invname.split("_");
			String serviceName = invt[0];
			
			if (serviceName.equals("TrackRidingCostsService")) {
				Label l = new Label(invname);
				l.setStyle("-fx-max-width: Infinity;" + 
						   "-fx-background-color: linear-gradient(to right, #7FFF00 0%, #F0FFFF 100%);" +
						   "-fx-padding: 6px;" +
						   "-fx-border-color: black;");
				Tooltip tp = new Tooltip();
				tp.setText(inv.getValue());
				l.setTooltip(tp);
				
				op_entity_invariants_label_map.put(invname, l);
				
				v.getChildren().add(l);
			}
		}
		opInvariantPanel.put("updateFareSuspensionWindow", v);
		
		v = new VBox();
		
		//entities invariants
		entities = TrackRidingCostsServiceImpl.opINVRelatedEntity.get("sendFareEstimationNotification");
		if (entities != null) {
			for (String opRelatedEntities : entities) {
				for (Entry<String, String> inv : entity_invariants_map.entrySet()) {
					
					String invname = inv.getKey();
					String[] invt = invname.split("_");
					String entityName = invt[0];
		
					if (opRelatedEntities.equals(entityName)) {
						Label l = new Label(invname);
						l.setStyle("-fx-max-width: Infinity;" + 
								"-fx-background-color: linear-gradient(to right, #7FFF00 0%, #F0FFFF 100%);" +
							    "-fx-padding: 6px;" +
							    "-fx-border-color: black;");
						Tooltip tp = new Tooltip();
						tp.setText(inv.getValue());
						l.setTooltip(tp);
						
						op_entity_invariants_label_map.put(invname, l);
						
						v.getChildren().add(l);
					}
				}
			}
		} else {
			Label l = new Label("sendFareEstimationNotification" + " is no related invariants");
			l.setPadding(new Insets(8, 8, 8, 8));
			v.getChildren().add(l);
		}
		
		//service invariants
		for (Entry<String, String> inv : service_invariants_map.entrySet()) {
			
			String invname = inv.getKey();
			String[] invt = invname.split("_");
			String serviceName = invt[0];
			
			if (serviceName.equals("TrackRidingCostsService")) {
				Label l = new Label(invname);
				l.setStyle("-fx-max-width: Infinity;" + 
						   "-fx-background-color: linear-gradient(to right, #7FFF00 0%, #F0FFFF 100%);" +
						   "-fx-padding: 6px;" +
						   "-fx-border-color: black;");
				Tooltip tp = new Tooltip();
				tp.setText(inv.getValue());
				l.setTooltip(tp);
				
				op_entity_invariants_label_map.put(invname, l);
				
				v.getChildren().add(l);
			}
		}
		opInvariantPanel.put("sendFareEstimationNotification", v);
		
		v = new VBox();
		
		//entities invariants
		entities = ProcessMaintenanceRequestsServiceImpl.opINVRelatedEntity.get("getVehicleLocation");
		if (entities != null) {
			for (String opRelatedEntities : entities) {
				for (Entry<String, String> inv : entity_invariants_map.entrySet()) {
					
					String invname = inv.getKey();
					String[] invt = invname.split("_");
					String entityName = invt[0];
		
					if (opRelatedEntities.equals(entityName)) {
						Label l = new Label(invname);
						l.setStyle("-fx-max-width: Infinity;" + 
								"-fx-background-color: linear-gradient(to right, #7FFF00 0%, #F0FFFF 100%);" +
							    "-fx-padding: 6px;" +
							    "-fx-border-color: black;");
						Tooltip tp = new Tooltip();
						tp.setText(inv.getValue());
						l.setTooltip(tp);
						
						op_entity_invariants_label_map.put(invname, l);
						
						v.getChildren().add(l);
					}
				}
			}
		} else {
			Label l = new Label("getVehicleLocation" + " is no related invariants");
			l.setPadding(new Insets(8, 8, 8, 8));
			v.getChildren().add(l);
		}
		
		//service invariants
		for (Entry<String, String> inv : service_invariants_map.entrySet()) {
			
			String invname = inv.getKey();
			String[] invt = invname.split("_");
			String serviceName = invt[0];
			
			if (serviceName.equals("ProcessMaintenanceRequestsService")) {
				Label l = new Label(invname);
				l.setStyle("-fx-max-width: Infinity;" + 
						   "-fx-background-color: linear-gradient(to right, #7FFF00 0%, #F0FFFF 100%);" +
						   "-fx-padding: 6px;" +
						   "-fx-border-color: black;");
				Tooltip tp = new Tooltip();
				tp.setText(inv.getValue());
				l.setTooltip(tp);
				
				op_entity_invariants_label_map.put(invname, l);
				
				v.getChildren().add(l);
			}
		}
		opInvariantPanel.put("getVehicleLocation", v);
		
		v = new VBox();
		
		//entities invariants
		entities = ProcessMaintenanceRequestsServiceImpl.opINVRelatedEntity.get("cacheReportData");
		if (entities != null) {
			for (String opRelatedEntities : entities) {
				for (Entry<String, String> inv : entity_invariants_map.entrySet()) {
					
					String invname = inv.getKey();
					String[] invt = invname.split("_");
					String entityName = invt[0];
		
					if (opRelatedEntities.equals(entityName)) {
						Label l = new Label(invname);
						l.setStyle("-fx-max-width: Infinity;" + 
								"-fx-background-color: linear-gradient(to right, #7FFF00 0%, #F0FFFF 100%);" +
							    "-fx-padding: 6px;" +
							    "-fx-border-color: black;");
						Tooltip tp = new Tooltip();
						tp.setText(inv.getValue());
						l.setTooltip(tp);
						
						op_entity_invariants_label_map.put(invname, l);
						
						v.getChildren().add(l);
					}
				}
			}
		} else {
			Label l = new Label("cacheReportData" + " is no related invariants");
			l.setPadding(new Insets(8, 8, 8, 8));
			v.getChildren().add(l);
		}
		
		//service invariants
		for (Entry<String, String> inv : service_invariants_map.entrySet()) {
			
			String invname = inv.getKey();
			String[] invt = invname.split("_");
			String serviceName = invt[0];
			
			if (serviceName.equals("ProcessMaintenanceRequestsService")) {
				Label l = new Label(invname);
				l.setStyle("-fx-max-width: Infinity;" + 
						   "-fx-background-color: linear-gradient(to right, #7FFF00 0%, #F0FFFF 100%);" +
						   "-fx-padding: 6px;" +
						   "-fx-border-color: black;");
				Tooltip tp = new Tooltip();
				tp.setText(inv.getValue());
				l.setTooltip(tp);
				
				op_entity_invariants_label_map.put(invname, l);
				
				v.getChildren().add(l);
			}
		}
		opInvariantPanel.put("cacheReportData", v);
		
		v = new VBox();
		
		//entities invariants
		entities = ProcessMaintenanceRequestsServiceImpl.opINVRelatedEntity.get("submitRepairWorkOrder");
		if (entities != null) {
			for (String opRelatedEntities : entities) {
				for (Entry<String, String> inv : entity_invariants_map.entrySet()) {
					
					String invname = inv.getKey();
					String[] invt = invname.split("_");
					String entityName = invt[0];
		
					if (opRelatedEntities.equals(entityName)) {
						Label l = new Label(invname);
						l.setStyle("-fx-max-width: Infinity;" + 
								"-fx-background-color: linear-gradient(to right, #7FFF00 0%, #F0FFFF 100%);" +
							    "-fx-padding: 6px;" +
							    "-fx-border-color: black;");
						Tooltip tp = new Tooltip();
						tp.setText(inv.getValue());
						l.setTooltip(tp);
						
						op_entity_invariants_label_map.put(invname, l);
						
						v.getChildren().add(l);
					}
				}
			}
		} else {
			Label l = new Label("submitRepairWorkOrder" + " is no related invariants");
			l.setPadding(new Insets(8, 8, 8, 8));
			v.getChildren().add(l);
		}
		
		//service invariants
		for (Entry<String, String> inv : service_invariants_map.entrySet()) {
			
			String invname = inv.getKey();
			String[] invt = invname.split("_");
			String serviceName = invt[0];
			
			if (serviceName.equals("ProcessMaintenanceRequestsService")) {
				Label l = new Label(invname);
				l.setStyle("-fx-max-width: Infinity;" + 
						   "-fx-background-color: linear-gradient(to right, #7FFF00 0%, #F0FFFF 100%);" +
						   "-fx-padding: 6px;" +
						   "-fx-border-color: black;");
				Tooltip tp = new Tooltip();
				tp.setText(inv.getValue());
				l.setTooltip(tp);
				
				op_entity_invariants_label_map.put(invname, l);
				
				v.getChildren().add(l);
			}
		}
		opInvariantPanel.put("submitRepairWorkOrder", v);
		
		
	}
	
	
	/*
	*  generate invariant panel
	*/
	public void genereateInvairantPanel() {
		
		service_invariants_label_map = new LinkedHashMap<String, Label>();
		entity_invariants_label_map = new LinkedHashMap<String, Label>();
		
		//entity_invariants_map
		VBox v = new VBox();
		//service invariants
		for (Entry<String, String> inv : service_invariants_map.entrySet()) {
			
			Label l = new Label(inv.getKey());
			l.setStyle("-fx-max-width: Infinity;" + 
					"-fx-background-color: linear-gradient(to right, #7FFF00 0%, #F0FFFF 100%);" +
				    "-fx-padding: 6px;" +
				    "-fx-border-color: black;");
			
			Tooltip tp = new Tooltip();
			tp.setText(inv.getValue());
			l.setTooltip(tp);
			
			service_invariants_label_map.put(inv.getKey(), l);
			v.getChildren().add(l);
			
		}
		//entity invariants
		for (Entry<String, String> inv : entity_invariants_map.entrySet()) {
			
			String INVname = inv.getKey();
			Label l = new Label(INVname);
			if (INVname.contains("AssociationInvariants")) {
				l.setStyle("-fx-max-width: Infinity;" + 
					"-fx-background-color: linear-gradient(to right, #099b17 0%, #F0FFFF 100%);" +
				    "-fx-padding: 6px;" +
				    "-fx-border-color: black;");
			} else {
				l.setStyle("-fx-max-width: Infinity;" + 
									"-fx-background-color: linear-gradient(to right, #7FFF00 0%, #F0FFFF 100%);" +
								    "-fx-padding: 6px;" +
								    "-fx-border-color: black;");
			}	
			Tooltip tp = new Tooltip();
			tp.setText(inv.getValue());
			l.setTooltip(tp);
			
			entity_invariants_label_map.put(inv.getKey(), l);
			v.getChildren().add(l);
			
		}
		ScrollPane scrollPane = new ScrollPane(v);
		scrollPane.setFitToWidth(true);
		all_invariant_pane.setMaxHeight(850);
		
		all_invariant_pane.setContent(scrollPane);
	}	
	
	
	
	/* 
	*	mainPane add listener
	*/
	public void setListeners() {
		 mainPane.getSelectionModel().selectedItemProperty().addListener((ov, oldTab, newTab) -> {
			 
			 	if (newTab.getText().equals("System State")) {
			 		System.out.println("refresh all");
			 		refreshAll();
			 	}
		    
		    });
	}
	
	
	//checking all invariants
	public void checkAllInvariants() {
		
		invairantPanelUpdate();
	
	}	
	
	//refresh all
	public void refreshAll() {
		
		invairantPanelUpdate();
		classStatisticUpdate();
		generateObjectTable();
	}
	
	
	//update association
	public void updateAssociation(String className) {
		
		for (AssociationInfo assoc : allassociationData.get(className)) {
			assoc.computeAssociationNumber();
		}
		
	}
	
	public void updateAssociation(String className, int index) {
		
		for (AssociationInfo assoc : allassociationData.get(className)) {
			assoc.computeAssociationNumber(index);
		}
		
	}	
	
	public void generateObjectTable() {
		
		allObjectTables = new LinkedHashMap<String, TableView>();
		
		TableView<Map<String, String>> tableUser = new TableView<Map<String, String>>();

		//super entity attribute column
		TableColumn<Map<String, String>, String> tableUser_DepositId = new TableColumn<Map<String, String>, String>("DepositId");
		tableUser_DepositId.setMinWidth("DepositId".length()*10);
		tableUser_DepositId.setCellValueFactory(new Callback<CellDataFeatures<Map<String, String>, String>, ObservableValue<String>>() {	   
			@Override
		    public ObservableValue<String> call(CellDataFeatures<Map<String, String>, String> data) {
		        return new ReadOnlyStringWrapper(data.getValue().get("DepositId"));
		    }
		});	
		tableUser.getColumns().add(tableUser_DepositId);
		TableColumn<Map<String, String>, String> tableUser_Amount = new TableColumn<Map<String, String>, String>("Amount");
		tableUser_Amount.setMinWidth("Amount".length()*10);
		tableUser_Amount.setCellValueFactory(new Callback<CellDataFeatures<Map<String, String>, String>, ObservableValue<String>>() {	   
			@Override
		    public ObservableValue<String> call(CellDataFeatures<Map<String, String>, String> data) {
		        return new ReadOnlyStringWrapper(data.getValue().get("Amount"));
		    }
		});	
		tableUser.getColumns().add(tableUser_Amount);
		TableColumn<Map<String, String>, String> tableUser_RefundStatus = new TableColumn<Map<String, String>, String>("RefundStatus");
		tableUser_RefundStatus.setMinWidth("RefundStatus".length()*10);
		tableUser_RefundStatus.setCellValueFactory(new Callback<CellDataFeatures<Map<String, String>, String>, ObservableValue<String>>() {	   
			@Override
		    public ObservableValue<String> call(CellDataFeatures<Map<String, String>, String> data) {
		        return new ReadOnlyStringWrapper(data.getValue().get("RefundStatus"));
		    }
		});	
		tableUser.getColumns().add(tableUser_RefundStatus);
						
		//attributes table column
		TableColumn<Map<String, String>, String> tableUser_UserId = new TableColumn<Map<String, String>, String>("UserId");
		tableUser_UserId.setMinWidth("UserId".length()*10);
		tableUser_UserId.setCellValueFactory(new Callback<CellDataFeatures<Map<String, String>, String>, ObservableValue<String>>() {	   
			@Override
		    public ObservableValue<String> call(CellDataFeatures<Map<String, String>, String> data) {
		        return new ReadOnlyStringWrapper(data.getValue().get("UserId"));
		    }
		});	
		tableUser.getColumns().add(tableUser_UserId);
		TableColumn<Map<String, String>, String> tableUser_Username = new TableColumn<Map<String, String>, String>("Username");
		tableUser_Username.setMinWidth("Username".length()*10);
		tableUser_Username.setCellValueFactory(new Callback<CellDataFeatures<Map<String, String>, String>, ObservableValue<String>>() {	   
			@Override
		    public ObservableValue<String> call(CellDataFeatures<Map<String, String>, String> data) {
		        return new ReadOnlyStringWrapper(data.getValue().get("Username"));
		    }
		});	
		tableUser.getColumns().add(tableUser_Username);
		TableColumn<Map<String, String>, String> tableUser_PhoneNumber = new TableColumn<Map<String, String>, String>("PhoneNumber");
		tableUser_PhoneNumber.setMinWidth("PhoneNumber".length()*10);
		tableUser_PhoneNumber.setCellValueFactory(new Callback<CellDataFeatures<Map<String, String>, String>, ObservableValue<String>>() {	   
			@Override
		    public ObservableValue<String> call(CellDataFeatures<Map<String, String>, String> data) {
		        return new ReadOnlyStringWrapper(data.getValue().get("PhoneNumber"));
		    }
		});	
		tableUser.getColumns().add(tableUser_PhoneNumber);
		TableColumn<Map<String, String>, String> tableUser_Balance = new TableColumn<Map<String, String>, String>("Balance");
		tableUser_Balance.setMinWidth("Balance".length()*10);
		tableUser_Balance.setCellValueFactory(new Callback<CellDataFeatures<Map<String, String>, String>, ObservableValue<String>>() {	   
			@Override
		    public ObservableValue<String> call(CellDataFeatures<Map<String, String>, String> data) {
		        return new ReadOnlyStringWrapper(data.getValue().get("Balance"));
		    }
		});	
		tableUser.getColumns().add(tableUser_Balance);
		
		//table data
		ObservableList<Map<String, String>> dataUser = FXCollections.observableArrayList();
		List<User> rsUser = EntityManager.getAllInstancesOf("User");
		for (User r : rsUser) {
			//table entry
			Map<String, String> unit = new HashMap<String, String>();
			if (r.getDepositId() != null)
				unit.put("DepositId", String.valueOf(r.getDepositId()));
			else
				unit.put("DepositId", "");
			unit.put("Amount", String.valueOf(r.getAmount()));
			unit.put("RefundStatus", String.valueOf(r.getRefundStatus()));
			
			if (r.getUserId() != null)
				unit.put("UserId", String.valueOf(r.getUserId()));
			else
				unit.put("UserId", "");
			if (r.getUsername() != null)
				unit.put("Username", String.valueOf(r.getUsername()));
			else
				unit.put("Username", "");
			if (r.getPhoneNumber() != null)
				unit.put("PhoneNumber", String.valueOf(r.getPhoneNumber()));
			else
				unit.put("PhoneNumber", "");
			if (r.getBalance() != null)
				unit.put("Balance", String.valueOf(r.getBalance()));
			else
				unit.put("Balance", "");

			dataUser.add(unit);
		}
		
		tableUser.getSelectionModel().selectedIndexProperty().addListener(
							 (observable, oldValue, newValue) ->  { 
							 										 //get selected index
							 										 objectindex = tableUser.getSelectionModel().getSelectedIndex();
							 			 				 			 System.out.println("select: " + objectindex);

							 			 				 			 //update association object information
							 			 				 			 if (objectindex != -1)
										 			 					 updateAssociation("User", objectindex);
							 			 				 			 
							 			 				 		  });
		
		tableUser.setItems(dataUser);
		allObjectTables.put("User", tableUser);
		
		TableView<Map<String, String>> tableThirdPartyAccount = new TableView<Map<String, String>>();

		//super entity attribute column
						
		//attributes table column
		TableColumn<Map<String, String>, String> tableThirdPartyAccount_AccountId = new TableColumn<Map<String, String>, String>("AccountId");
		tableThirdPartyAccount_AccountId.setMinWidth("AccountId".length()*10);
		tableThirdPartyAccount_AccountId.setCellValueFactory(new Callback<CellDataFeatures<Map<String, String>, String>, ObservableValue<String>>() {	   
			@Override
		    public ObservableValue<String> call(CellDataFeatures<Map<String, String>, String> data) {
		        return new ReadOnlyStringWrapper(data.getValue().get("AccountId"));
		    }
		});	
		tableThirdPartyAccount.getColumns().add(tableThirdPartyAccount_AccountId);
		TableColumn<Map<String, String>, String> tableThirdPartyAccount_BindingStatus = new TableColumn<Map<String, String>, String>("BindingStatus");
		tableThirdPartyAccount_BindingStatus.setMinWidth("BindingStatus".length()*10);
		tableThirdPartyAccount_BindingStatus.setCellValueFactory(new Callback<CellDataFeatures<Map<String, String>, String>, ObservableValue<String>>() {	   
			@Override
		    public ObservableValue<String> call(CellDataFeatures<Map<String, String>, String> data) {
		        return new ReadOnlyStringWrapper(data.getValue().get("BindingStatus"));
		    }
		});	
		tableThirdPartyAccount.getColumns().add(tableThirdPartyAccount_BindingStatus);
		
		//table data
		ObservableList<Map<String, String>> dataThirdPartyAccount = FXCollections.observableArrayList();
		List<ThirdPartyAccount> rsThirdPartyAccount = EntityManager.getAllInstancesOf("ThirdPartyAccount");
		for (ThirdPartyAccount r : rsThirdPartyAccount) {
			//table entry
			Map<String, String> unit = new HashMap<String, String>();
			
			if (r.getAccountId() != null)
				unit.put("AccountId", String.valueOf(r.getAccountId()));
			else
				unit.put("AccountId", "");
			unit.put("BindingStatus", String.valueOf(r.getBindingStatus()));

			dataThirdPartyAccount.add(unit);
		}
		
		tableThirdPartyAccount.getSelectionModel().selectedIndexProperty().addListener(
							 (observable, oldValue, newValue) ->  { 
							 										 //get selected index
							 										 objectindex = tableThirdPartyAccount.getSelectionModel().getSelectedIndex();
							 			 				 			 System.out.println("select: " + objectindex);

							 			 				 			 //update association object information
							 			 				 			 if (objectindex != -1)
										 			 					 updateAssociation("ThirdPartyAccount", objectindex);
							 			 				 			 
							 			 				 		  });
		
		tableThirdPartyAccount.setItems(dataThirdPartyAccount);
		allObjectTables.put("ThirdPartyAccount", tableThirdPartyAccount);
		
		TableView<Map<String, String>> tableDeposit = new TableView<Map<String, String>>();

		//super entity attribute column
						
		//attributes table column
		TableColumn<Map<String, String>, String> tableDeposit_DepositId = new TableColumn<Map<String, String>, String>("DepositId");
		tableDeposit_DepositId.setMinWidth("DepositId".length()*10);
		tableDeposit_DepositId.setCellValueFactory(new Callback<CellDataFeatures<Map<String, String>, String>, ObservableValue<String>>() {	   
			@Override
		    public ObservableValue<String> call(CellDataFeatures<Map<String, String>, String> data) {
		        return new ReadOnlyStringWrapper(data.getValue().get("DepositId"));
		    }
		});	
		tableDeposit.getColumns().add(tableDeposit_DepositId);
		TableColumn<Map<String, String>, String> tableDeposit_Amount = new TableColumn<Map<String, String>, String>("Amount");
		tableDeposit_Amount.setMinWidth("Amount".length()*10);
		tableDeposit_Amount.setCellValueFactory(new Callback<CellDataFeatures<Map<String, String>, String>, ObservableValue<String>>() {	   
			@Override
		    public ObservableValue<String> call(CellDataFeatures<Map<String, String>, String> data) {
		        return new ReadOnlyStringWrapper(data.getValue().get("Amount"));
		    }
		});	
		tableDeposit.getColumns().add(tableDeposit_Amount);
		TableColumn<Map<String, String>, String> tableDeposit_RefundStatus = new TableColumn<Map<String, String>, String>("RefundStatus");
		tableDeposit_RefundStatus.setMinWidth("RefundStatus".length()*10);
		tableDeposit_RefundStatus.setCellValueFactory(new Callback<CellDataFeatures<Map<String, String>, String>, ObservableValue<String>>() {	   
			@Override
		    public ObservableValue<String> call(CellDataFeatures<Map<String, String>, String> data) {
		        return new ReadOnlyStringWrapper(data.getValue().get("RefundStatus"));
		    }
		});	
		tableDeposit.getColumns().add(tableDeposit_RefundStatus);
		
		//table data
		ObservableList<Map<String, String>> dataDeposit = FXCollections.observableArrayList();
		List<Deposit> rsDeposit = EntityManager.getAllInstancesOf("Deposit");
		for (Deposit r : rsDeposit) {
			//table entry
			Map<String, String> unit = new HashMap<String, String>();
			
			if (r.getDepositId() != null)
				unit.put("DepositId", String.valueOf(r.getDepositId()));
			else
				unit.put("DepositId", "");
			unit.put("Amount", String.valueOf(r.getAmount()));
			unit.put("RefundStatus", String.valueOf(r.getRefundStatus()));

			dataDeposit.add(unit);
		}
		
		tableDeposit.getSelectionModel().selectedIndexProperty().addListener(
							 (observable, oldValue, newValue) ->  { 
							 										 //get selected index
							 										 objectindex = tableDeposit.getSelectionModel().getSelectedIndex();
							 			 				 			 System.out.println("select: " + objectindex);

							 			 				 			 //update association object information
							 			 				 			 if (objectindex != -1)
										 			 					 updateAssociation("Deposit", objectindex);
							 			 				 			 
							 			 				 		  });
		
		tableDeposit.setItems(dataDeposit);
		allObjectTables.put("Deposit", tableDeposit);
		
		TableView<Map<String, String>> tableBike = new TableView<Map<String, String>>();

		//super entity attribute column
						
		//attributes table column
		TableColumn<Map<String, String>, String> tableBike_BikeId = new TableColumn<Map<String, String>, String>("BikeId");
		tableBike_BikeId.setMinWidth("BikeId".length()*10);
		tableBike_BikeId.setCellValueFactory(new Callback<CellDataFeatures<Map<String, String>, String>, ObservableValue<String>>() {	   
			@Override
		    public ObservableValue<String> call(CellDataFeatures<Map<String, String>, String> data) {
		        return new ReadOnlyStringWrapper(data.getValue().get("BikeId"));
		    }
		});	
		tableBike.getColumns().add(tableBike_BikeId);
		TableColumn<Map<String, String>, String> tableBike_Location = new TableColumn<Map<String, String>, String>("Location");
		tableBike_Location.setMinWidth("Location".length()*10);
		tableBike_Location.setCellValueFactory(new Callback<CellDataFeatures<Map<String, String>, String>, ObservableValue<String>>() {	   
			@Override
		    public ObservableValue<String> call(CellDataFeatures<Map<String, String>, String> data) {
		        return new ReadOnlyStringWrapper(data.getValue().get("Location"));
		    }
		});	
		tableBike.getColumns().add(tableBike_Location);
		TableColumn<Map<String, String>, String> tableBike_Status = new TableColumn<Map<String, String>, String>("Status");
		tableBike_Status.setMinWidth("Status".length()*10);
		tableBike_Status.setCellValueFactory(new Callback<CellDataFeatures<Map<String, String>, String>, ObservableValue<String>>() {	   
			@Override
		    public ObservableValue<String> call(CellDataFeatures<Map<String, String>, String> data) {
		        return new ReadOnlyStringWrapper(data.getValue().get("Status"));
		    }
		});	
		tableBike.getColumns().add(tableBike_Status);
		
		//table data
		ObservableList<Map<String, String>> dataBike = FXCollections.observableArrayList();
		List<Bike> rsBike = EntityManager.getAllInstancesOf("Bike");
		for (Bike r : rsBike) {
			//table entry
			Map<String, String> unit = new HashMap<String, String>();
			
			if (r.getBikeId() != null)
				unit.put("BikeId", String.valueOf(r.getBikeId()));
			else
				unit.put("BikeId", "");
			if (r.getLocation() != null)
				unit.put("Location", String.valueOf(r.getLocation()));
			else
				unit.put("Location", "");
			if (r.getStatus() != null)
				unit.put("Status", String.valueOf(r.getStatus()));
			else
				unit.put("Status", "");

			dataBike.add(unit);
		}
		
		tableBike.getSelectionModel().selectedIndexProperty().addListener(
							 (observable, oldValue, newValue) ->  { 
							 										 //get selected index
							 										 objectindex = tableBike.getSelectionModel().getSelectedIndex();
							 			 				 			 System.out.println("select: " + objectindex);

							 			 				 			 //update association object information
							 			 				 			 if (objectindex != -1)
										 			 					 updateAssociation("Bike", objectindex);
							 			 				 			 
							 			 				 		  });
		
		tableBike.setItems(dataBike);
		allObjectTables.put("Bike", tableBike);
		
		TableView<Map<String, String>> tableOrder = new TableView<Map<String, String>>();

		//super entity attribute column
						
		//attributes table column
		TableColumn<Map<String, String>, String> tableOrder_OrderId = new TableColumn<Map<String, String>, String>("OrderId");
		tableOrder_OrderId.setMinWidth("OrderId".length()*10);
		tableOrder_OrderId.setCellValueFactory(new Callback<CellDataFeatures<Map<String, String>, String>, ObservableValue<String>>() {	   
			@Override
		    public ObservableValue<String> call(CellDataFeatures<Map<String, String>, String> data) {
		        return new ReadOnlyStringWrapper(data.getValue().get("OrderId"));
		    }
		});	
		tableOrder.getColumns().add(tableOrder_OrderId);
		TableColumn<Map<String, String>, String> tableOrder_StartTime = new TableColumn<Map<String, String>, String>("StartTime");
		tableOrder_StartTime.setMinWidth("StartTime".length()*10);
		tableOrder_StartTime.setCellValueFactory(new Callback<CellDataFeatures<Map<String, String>, String>, ObservableValue<String>>() {	   
			@Override
		    public ObservableValue<String> call(CellDataFeatures<Map<String, String>, String> data) {
		        return new ReadOnlyStringWrapper(data.getValue().get("StartTime"));
		    }
		});	
		tableOrder.getColumns().add(tableOrder_StartTime);
		TableColumn<Map<String, String>, String> tableOrder_EndTime = new TableColumn<Map<String, String>, String>("EndTime");
		tableOrder_EndTime.setMinWidth("EndTime".length()*10);
		tableOrder_EndTime.setCellValueFactory(new Callback<CellDataFeatures<Map<String, String>, String>, ObservableValue<String>>() {	   
			@Override
		    public ObservableValue<String> call(CellDataFeatures<Map<String, String>, String> data) {
		        return new ReadOnlyStringWrapper(data.getValue().get("EndTime"));
		    }
		});	
		tableOrder.getColumns().add(tableOrder_EndTime);
		TableColumn<Map<String, String>, String> tableOrder_Distance = new TableColumn<Map<String, String>, String>("Distance");
		tableOrder_Distance.setMinWidth("Distance".length()*10);
		tableOrder_Distance.setCellValueFactory(new Callback<CellDataFeatures<Map<String, String>, String>, ObservableValue<String>>() {	   
			@Override
		    public ObservableValue<String> call(CellDataFeatures<Map<String, String>, String> data) {
		        return new ReadOnlyStringWrapper(data.getValue().get("Distance"));
		    }
		});	
		tableOrder.getColumns().add(tableOrder_Distance);
		
		//table data
		ObservableList<Map<String, String>> dataOrder = FXCollections.observableArrayList();
		List<Order> rsOrder = EntityManager.getAllInstancesOf("Order");
		for (Order r : rsOrder) {
			//table entry
			Map<String, String> unit = new HashMap<String, String>();
			
			if (r.getOrderId() != null)
				unit.put("OrderId", String.valueOf(r.getOrderId()));
			else
				unit.put("OrderId", "");
			if (r.getStartTime() != null)
				unit.put("StartTime", r.getStartTime().format(dateformatter));
			else
				unit.put("StartTime", "");
			if (r.getEndTime() != null)
				unit.put("EndTime", r.getEndTime().format(dateformatter));
			else
				unit.put("EndTime", "");
			unit.put("Distance", String.valueOf(r.getDistance()));

			dataOrder.add(unit);
		}
		
		tableOrder.getSelectionModel().selectedIndexProperty().addListener(
							 (observable, oldValue, newValue) ->  { 
							 										 //get selected index
							 										 objectindex = tableOrder.getSelectionModel().getSelectedIndex();
							 			 				 			 System.out.println("select: " + objectindex);

							 			 				 			 //update association object information
							 			 				 			 if (objectindex != -1)
										 			 					 updateAssociation("Order", objectindex);
							 			 				 			 
							 			 				 		  });
		
		tableOrder.setItems(dataOrder);
		allObjectTables.put("Order", tableOrder);
		
		TableView<Map<String, String>> tableFaultReport = new TableView<Map<String, String>>();

		//super entity attribute column
						
		//attributes table column
		TableColumn<Map<String, String>, String> tableFaultReport_RepritId = new TableColumn<Map<String, String>, String>("RepritId");
		tableFaultReport_RepritId.setMinWidth("RepritId".length()*10);
		tableFaultReport_RepritId.setCellValueFactory(new Callback<CellDataFeatures<Map<String, String>, String>, ObservableValue<String>>() {	   
			@Override
		    public ObservableValue<String> call(CellDataFeatures<Map<String, String>, String> data) {
		        return new ReadOnlyStringWrapper(data.getValue().get("RepritId"));
		    }
		});	
		tableFaultReport.getColumns().add(tableFaultReport_RepritId);
		TableColumn<Map<String, String>, String> tableFaultReport_FaultType = new TableColumn<Map<String, String>, String>("FaultType");
		tableFaultReport_FaultType.setMinWidth("FaultType".length()*10);
		tableFaultReport_FaultType.setCellValueFactory(new Callback<CellDataFeatures<Map<String, String>, String>, ObservableValue<String>>() {	   
			@Override
		    public ObservableValue<String> call(CellDataFeatures<Map<String, String>, String> data) {
		        return new ReadOnlyStringWrapper(data.getValue().get("FaultType"));
		    }
		});	
		tableFaultReport.getColumns().add(tableFaultReport_FaultType);
		TableColumn<Map<String, String>, String> tableFaultReport_Photos = new TableColumn<Map<String, String>, String>("Photos");
		tableFaultReport_Photos.setMinWidth("Photos".length()*10);
		tableFaultReport_Photos.setCellValueFactory(new Callback<CellDataFeatures<Map<String, String>, String>, ObservableValue<String>>() {	   
			@Override
		    public ObservableValue<String> call(CellDataFeatures<Map<String, String>, String> data) {
		        return new ReadOnlyStringWrapper(data.getValue().get("Photos"));
		    }
		});	
		tableFaultReport.getColumns().add(tableFaultReport_Photos);
		
		//table data
		ObservableList<Map<String, String>> dataFaultReport = FXCollections.observableArrayList();
		List<FaultReport> rsFaultReport = EntityManager.getAllInstancesOf("FaultReport");
		for (FaultReport r : rsFaultReport) {
			//table entry
			Map<String, String> unit = new HashMap<String, String>();
			
			if (r.getRepritId() != null)
				unit.put("RepritId", String.valueOf(r.getRepritId()));
			else
				unit.put("RepritId", "");
			if (r.getFaultType() != null)
				unit.put("FaultType", String.valueOf(r.getFaultType()));
			else
				unit.put("FaultType", "");
			if (r.getPhotos() != null)
				unit.put("Photos", String.valueOf(r.getPhotos()));
			else
				unit.put("Photos", "");

			dataFaultReport.add(unit);
		}
		
		tableFaultReport.getSelectionModel().selectedIndexProperty().addListener(
							 (observable, oldValue, newValue) ->  { 
							 										 //get selected index
							 										 objectindex = tableFaultReport.getSelectionModel().getSelectedIndex();
							 			 				 			 System.out.println("select: " + objectindex);

							 			 				 			 //update association object information
							 			 				 			 if (objectindex != -1)
										 			 					 updateAssociation("FaultReport", objectindex);
							 			 				 			 
							 			 				 		  });
		
		tableFaultReport.setItems(dataFaultReport);
		allObjectTables.put("FaultReport", tableFaultReport);
		
		TableView<Map<String, String>> tablePaymentMethod = new TableView<Map<String, String>>();

		//super entity attribute column
						
		//attributes table column
		TableColumn<Map<String, String>, String> tablePaymentMethod_PaymentId = new TableColumn<Map<String, String>, String>("PaymentId");
		tablePaymentMethod_PaymentId.setMinWidth("PaymentId".length()*10);
		tablePaymentMethod_PaymentId.setCellValueFactory(new Callback<CellDataFeatures<Map<String, String>, String>, ObservableValue<String>>() {	   
			@Override
		    public ObservableValue<String> call(CellDataFeatures<Map<String, String>, String> data) {
		        return new ReadOnlyStringWrapper(data.getValue().get("PaymentId"));
		    }
		});	
		tablePaymentMethod.getColumns().add(tablePaymentMethod_PaymentId);
		TableColumn<Map<String, String>, String> tablePaymentMethod_PaymentType = new TableColumn<Map<String, String>, String>("PaymentType");
		tablePaymentMethod_PaymentType.setMinWidth("PaymentType".length()*10);
		tablePaymentMethod_PaymentType.setCellValueFactory(new Callback<CellDataFeatures<Map<String, String>, String>, ObservableValue<String>>() {	   
			@Override
		    public ObservableValue<String> call(CellDataFeatures<Map<String, String>, String> data) {
		        return new ReadOnlyStringWrapper(data.getValue().get("PaymentType"));
		    }
		});	
		tablePaymentMethod.getColumns().add(tablePaymentMethod_PaymentType);
		
		//table data
		ObservableList<Map<String, String>> dataPaymentMethod = FXCollections.observableArrayList();
		List<PaymentMethod> rsPaymentMethod = EntityManager.getAllInstancesOf("PaymentMethod");
		for (PaymentMethod r : rsPaymentMethod) {
			//table entry
			Map<String, String> unit = new HashMap<String, String>();
			
			if (r.getPaymentId() != null)
				unit.put("PaymentId", String.valueOf(r.getPaymentId()));
			else
				unit.put("PaymentId", "");
			if (r.getPaymentType() != null)
				unit.put("PaymentType", String.valueOf(r.getPaymentType()));
			else
				unit.put("PaymentType", "");

			dataPaymentMethod.add(unit);
		}
		
		tablePaymentMethod.getSelectionModel().selectedIndexProperty().addListener(
							 (observable, oldValue, newValue) ->  { 
							 										 //get selected index
							 										 objectindex = tablePaymentMethod.getSelectionModel().getSelectedIndex();
							 			 				 			 System.out.println("select: " + objectindex);

							 			 				 			 //update association object information
							 			 				 			 if (objectindex != -1)
										 			 					 updateAssociation("PaymentMethod", objectindex);
							 			 				 			 
							 			 				 		  });
		
		tablePaymentMethod.setItems(dataPaymentMethod);
		allObjectTables.put("PaymentMethod", tablePaymentMethod);
		
		TableView<Map<String, String>> tableCoupon = new TableView<Map<String, String>>();

		//super entity attribute column
						
		//attributes table column
		TableColumn<Map<String, String>, String> tableCoupon_CouponId = new TableColumn<Map<String, String>, String>("CouponId");
		tableCoupon_CouponId.setMinWidth("CouponId".length()*10);
		tableCoupon_CouponId.setCellValueFactory(new Callback<CellDataFeatures<Map<String, String>, String>, ObservableValue<String>>() {	   
			@Override
		    public ObservableValue<String> call(CellDataFeatures<Map<String, String>, String> data) {
		        return new ReadOnlyStringWrapper(data.getValue().get("CouponId"));
		    }
		});	
		tableCoupon.getColumns().add(tableCoupon_CouponId);
		TableColumn<Map<String, String>, String> tableCoupon_CouponType = new TableColumn<Map<String, String>, String>("CouponType");
		tableCoupon_CouponType.setMinWidth("CouponType".length()*10);
		tableCoupon_CouponType.setCellValueFactory(new Callback<CellDataFeatures<Map<String, String>, String>, ObservableValue<String>>() {	   
			@Override
		    public ObservableValue<String> call(CellDataFeatures<Map<String, String>, String> data) {
		        return new ReadOnlyStringWrapper(data.getValue().get("CouponType"));
		    }
		});	
		tableCoupon.getColumns().add(tableCoupon_CouponType);
		TableColumn<Map<String, String>, String> tableCoupon_ValidPeriod = new TableColumn<Map<String, String>, String>("ValidPeriod");
		tableCoupon_ValidPeriod.setMinWidth("ValidPeriod".length()*10);
		tableCoupon_ValidPeriod.setCellValueFactory(new Callback<CellDataFeatures<Map<String, String>, String>, ObservableValue<String>>() {	   
			@Override
		    public ObservableValue<String> call(CellDataFeatures<Map<String, String>, String> data) {
		        return new ReadOnlyStringWrapper(data.getValue().get("ValidPeriod"));
		    }
		});	
		tableCoupon.getColumns().add(tableCoupon_ValidPeriod);
		
		//table data
		ObservableList<Map<String, String>> dataCoupon = FXCollections.observableArrayList();
		List<Coupon> rsCoupon = EntityManager.getAllInstancesOf("Coupon");
		for (Coupon r : rsCoupon) {
			//table entry
			Map<String, String> unit = new HashMap<String, String>();
			
			if (r.getCouponId() != null)
				unit.put("CouponId", String.valueOf(r.getCouponId()));
			else
				unit.put("CouponId", "");
			if (r.getCouponType() != null)
				unit.put("CouponType", String.valueOf(r.getCouponType()));
			else
				unit.put("CouponType", "");
			if (r.getValidPeriod() != null)
				unit.put("ValidPeriod", r.getValidPeriod().format(dateformatter));
			else
				unit.put("ValidPeriod", "");

			dataCoupon.add(unit);
		}
		
		tableCoupon.getSelectionModel().selectedIndexProperty().addListener(
							 (observable, oldValue, newValue) ->  { 
							 										 //get selected index
							 										 objectindex = tableCoupon.getSelectionModel().getSelectedIndex();
							 			 				 			 System.out.println("select: " + objectindex);

							 			 				 			 //update association object information
							 			 				 			 if (objectindex != -1)
										 			 					 updateAssociation("Coupon", objectindex);
							 			 				 			 
							 			 				 		  });
		
		tableCoupon.setItems(dataCoupon);
		allObjectTables.put("Coupon", tableCoupon);
		
		TableView<Map<String, String>> tableGeoPoint = new TableView<Map<String, String>>();

		//super entity attribute column
						
		//attributes table column
		TableColumn<Map<String, String>, String> tableGeoPoint_Latitude = new TableColumn<Map<String, String>, String>("Latitude");
		tableGeoPoint_Latitude.setMinWidth("Latitude".length()*10);
		tableGeoPoint_Latitude.setCellValueFactory(new Callback<CellDataFeatures<Map<String, String>, String>, ObservableValue<String>>() {	   
			@Override
		    public ObservableValue<String> call(CellDataFeatures<Map<String, String>, String> data) {
		        return new ReadOnlyStringWrapper(data.getValue().get("Latitude"));
		    }
		});	
		tableGeoPoint.getColumns().add(tableGeoPoint_Latitude);
		TableColumn<Map<String, String>, String> tableGeoPoint_Longitude = new TableColumn<Map<String, String>, String>("Longitude");
		tableGeoPoint_Longitude.setMinWidth("Longitude".length()*10);
		tableGeoPoint_Longitude.setCellValueFactory(new Callback<CellDataFeatures<Map<String, String>, String>, ObservableValue<String>>() {	   
			@Override
		    public ObservableValue<String> call(CellDataFeatures<Map<String, String>, String> data) {
		        return new ReadOnlyStringWrapper(data.getValue().get("Longitude"));
		    }
		});	
		tableGeoPoint.getColumns().add(tableGeoPoint_Longitude);
		
		//table data
		ObservableList<Map<String, String>> dataGeoPoint = FXCollections.observableArrayList();
		List<GeoPoint> rsGeoPoint = EntityManager.getAllInstancesOf("GeoPoint");
		for (GeoPoint r : rsGeoPoint) {
			//table entry
			Map<String, String> unit = new HashMap<String, String>();
			
			if (r.getLatitude() != null)
				unit.put("Latitude", String.valueOf(r.getLatitude()));
			else
				unit.put("Latitude", "");
			if (r.getLongitude() != null)
				unit.put("Longitude", String.valueOf(r.getLongitude()));
			else
				unit.put("Longitude", "");

			dataGeoPoint.add(unit);
		}
		
		tableGeoPoint.getSelectionModel().selectedIndexProperty().addListener(
							 (observable, oldValue, newValue) ->  { 
							 										 //get selected index
							 										 objectindex = tableGeoPoint.getSelectionModel().getSelectedIndex();
							 			 				 			 System.out.println("select: " + objectindex);

							 			 				 			 //update association object information
							 			 				 			 if (objectindex != -1)
										 			 					 updateAssociation("GeoPoint", objectindex);
							 			 				 			 
							 			 				 		  });
		
		tableGeoPoint.setItems(dataGeoPoint);
		allObjectTables.put("GeoPoint", tableGeoPoint);
		
		TableView<Map<String, String>> tableWeChatPayment = new TableView<Map<String, String>>();

		//super entity attribute column
		TableColumn<Map<String, String>, String> tableWeChatPayment_PaymentId = new TableColumn<Map<String, String>, String>("PaymentId");
		tableWeChatPayment_PaymentId.setMinWidth("PaymentId".length()*10);
		tableWeChatPayment_PaymentId.setCellValueFactory(new Callback<CellDataFeatures<Map<String, String>, String>, ObservableValue<String>>() {	   
			@Override
		    public ObservableValue<String> call(CellDataFeatures<Map<String, String>, String> data) {
		        return new ReadOnlyStringWrapper(data.getValue().get("PaymentId"));
		    }
		});	
		tableWeChatPayment.getColumns().add(tableWeChatPayment_PaymentId);
		TableColumn<Map<String, String>, String> tableWeChatPayment_PaymentType = new TableColumn<Map<String, String>, String>("PaymentType");
		tableWeChatPayment_PaymentType.setMinWidth("PaymentType".length()*10);
		tableWeChatPayment_PaymentType.setCellValueFactory(new Callback<CellDataFeatures<Map<String, String>, String>, ObservableValue<String>>() {	   
			@Override
		    public ObservableValue<String> call(CellDataFeatures<Map<String, String>, String> data) {
		        return new ReadOnlyStringWrapper(data.getValue().get("PaymentType"));
		    }
		});	
		tableWeChatPayment.getColumns().add(tableWeChatPayment_PaymentType);
						
		//attributes table column
		TableColumn<Map<String, String>, String> tableWeChatPayment_OpenId = new TableColumn<Map<String, String>, String>("OpenId");
		tableWeChatPayment_OpenId.setMinWidth("OpenId".length()*10);
		tableWeChatPayment_OpenId.setCellValueFactory(new Callback<CellDataFeatures<Map<String, String>, String>, ObservableValue<String>>() {	   
			@Override
		    public ObservableValue<String> call(CellDataFeatures<Map<String, String>, String> data) {
		        return new ReadOnlyStringWrapper(data.getValue().get("OpenId"));
		    }
		});	
		tableWeChatPayment.getColumns().add(tableWeChatPayment_OpenId);
		
		//table data
		ObservableList<Map<String, String>> dataWeChatPayment = FXCollections.observableArrayList();
		List<WeChatPayment> rsWeChatPayment = EntityManager.getAllInstancesOf("WeChatPayment");
		for (WeChatPayment r : rsWeChatPayment) {
			//table entry
			Map<String, String> unit = new HashMap<String, String>();
			if (r.getPaymentId() != null)
				unit.put("PaymentId", String.valueOf(r.getPaymentId()));
			else
				unit.put("PaymentId", "");
			if (r.getPaymentType() != null)
				unit.put("PaymentType", String.valueOf(r.getPaymentType()));
			else
				unit.put("PaymentType", "");
			
			if (r.getOpenId() != null)
				unit.put("OpenId", String.valueOf(r.getOpenId()));
			else
				unit.put("OpenId", "");

			dataWeChatPayment.add(unit);
		}
		
		tableWeChatPayment.getSelectionModel().selectedIndexProperty().addListener(
							 (observable, oldValue, newValue) ->  { 
							 										 //get selected index
							 										 objectindex = tableWeChatPayment.getSelectionModel().getSelectedIndex();
							 			 				 			 System.out.println("select: " + objectindex);

							 			 				 			 //update association object information
							 			 				 			 if (objectindex != -1)
										 			 					 updateAssociation("WeChatPayment", objectindex);
							 			 				 			 
							 			 				 		  });
		
		tableWeChatPayment.setItems(dataWeChatPayment);
		allObjectTables.put("WeChatPayment", tableWeChatPayment);
		
		TableView<Map<String, String>> tableAlipayUserId = new TableView<Map<String, String>>();

		//super entity attribute column
		TableColumn<Map<String, String>, String> tableAlipayUserId_PaymentId = new TableColumn<Map<String, String>, String>("PaymentId");
		tableAlipayUserId_PaymentId.setMinWidth("PaymentId".length()*10);
		tableAlipayUserId_PaymentId.setCellValueFactory(new Callback<CellDataFeatures<Map<String, String>, String>, ObservableValue<String>>() {	   
			@Override
		    public ObservableValue<String> call(CellDataFeatures<Map<String, String>, String> data) {
		        return new ReadOnlyStringWrapper(data.getValue().get("PaymentId"));
		    }
		});	
		tableAlipayUserId.getColumns().add(tableAlipayUserId_PaymentId);
		TableColumn<Map<String, String>, String> tableAlipayUserId_PaymentType = new TableColumn<Map<String, String>, String>("PaymentType");
		tableAlipayUserId_PaymentType.setMinWidth("PaymentType".length()*10);
		tableAlipayUserId_PaymentType.setCellValueFactory(new Callback<CellDataFeatures<Map<String, String>, String>, ObservableValue<String>>() {	   
			@Override
		    public ObservableValue<String> call(CellDataFeatures<Map<String, String>, String> data) {
		        return new ReadOnlyStringWrapper(data.getValue().get("PaymentType"));
		    }
		});	
		tableAlipayUserId.getColumns().add(tableAlipayUserId_PaymentType);
						
		//attributes table column
		TableColumn<Map<String, String>, String> tableAlipayUserId_AlipayUserId = new TableColumn<Map<String, String>, String>("AlipayUserId");
		tableAlipayUserId_AlipayUserId.setMinWidth("AlipayUserId".length()*10);
		tableAlipayUserId_AlipayUserId.setCellValueFactory(new Callback<CellDataFeatures<Map<String, String>, String>, ObservableValue<String>>() {	   
			@Override
		    public ObservableValue<String> call(CellDataFeatures<Map<String, String>, String> data) {
		        return new ReadOnlyStringWrapper(data.getValue().get("AlipayUserId"));
		    }
		});	
		tableAlipayUserId.getColumns().add(tableAlipayUserId_AlipayUserId);
		
		//table data
		ObservableList<Map<String, String>> dataAlipayUserId = FXCollections.observableArrayList();
		List<AlipayUserId> rsAlipayUserId = EntityManager.getAllInstancesOf("AlipayUserId");
		for (AlipayUserId r : rsAlipayUserId) {
			//table entry
			Map<String, String> unit = new HashMap<String, String>();
			if (r.getPaymentId() != null)
				unit.put("PaymentId", String.valueOf(r.getPaymentId()));
			else
				unit.put("PaymentId", "");
			if (r.getPaymentType() != null)
				unit.put("PaymentType", String.valueOf(r.getPaymentType()));
			else
				unit.put("PaymentType", "");
			
			if (r.getAlipayUserId() != null)
				unit.put("AlipayUserId", String.valueOf(r.getAlipayUserId()));
			else
				unit.put("AlipayUserId", "");

			dataAlipayUserId.add(unit);
		}
		
		tableAlipayUserId.getSelectionModel().selectedIndexProperty().addListener(
							 (observable, oldValue, newValue) ->  { 
							 										 //get selected index
							 										 objectindex = tableAlipayUserId.getSelectionModel().getSelectedIndex();
							 			 				 			 System.out.println("select: " + objectindex);

							 			 				 			 //update association object information
							 			 				 			 if (objectindex != -1)
										 			 					 updateAssociation("AlipayUserId", objectindex);
							 			 				 			 
							 			 				 		  });
		
		tableAlipayUserId.setItems(dataAlipayUserId);
		allObjectTables.put("AlipayUserId", tableAlipayUserId);
		

		
	}
	
	/* 
	* update all object tables with sub dataset
	*/ 
	public void updateUserTable(List<User> rsUser) {
			ObservableList<Map<String, String>> dataUser = FXCollections.observableArrayList();
			for (User r : rsUser) {
				Map<String, String> unit = new HashMap<String, String>();
				
				if (r.getDepositId() != null)
					unit.put("DepositId", String.valueOf(r.getDepositId()));
				else
					unit.put("DepositId", "");
				unit.put("Amount", String.valueOf(r.getAmount()));
				unit.put("RefundStatus", String.valueOf(r.getRefundStatus()));
				
				if (r.getUserId() != null)
					unit.put("UserId", String.valueOf(r.getUserId()));
				else
					unit.put("UserId", "");
				if (r.getUsername() != null)
					unit.put("Username", String.valueOf(r.getUsername()));
				else
					unit.put("Username", "");
				if (r.getPhoneNumber() != null)
					unit.put("PhoneNumber", String.valueOf(r.getPhoneNumber()));
				else
					unit.put("PhoneNumber", "");
				if (r.getBalance() != null)
					unit.put("Balance", String.valueOf(r.getBalance()));
				else
					unit.put("Balance", "");
				dataUser.add(unit);
			}
			
			allObjectTables.get("User").setItems(dataUser);
	}
	public void updateThirdPartyAccountTable(List<ThirdPartyAccount> rsThirdPartyAccount) {
			ObservableList<Map<String, String>> dataThirdPartyAccount = FXCollections.observableArrayList();
			for (ThirdPartyAccount r : rsThirdPartyAccount) {
				Map<String, String> unit = new HashMap<String, String>();
				
				
				if (r.getAccountId() != null)
					unit.put("AccountId", String.valueOf(r.getAccountId()));
				else
					unit.put("AccountId", "");
				unit.put("BindingStatus", String.valueOf(r.getBindingStatus()));
				dataThirdPartyAccount.add(unit);
			}
			
			allObjectTables.get("ThirdPartyAccount").setItems(dataThirdPartyAccount);
	}
	public void updateDepositTable(List<Deposit> rsDeposit) {
			ObservableList<Map<String, String>> dataDeposit = FXCollections.observableArrayList();
			for (Deposit r : rsDeposit) {
				Map<String, String> unit = new HashMap<String, String>();
				
				
				if (r.getDepositId() != null)
					unit.put("DepositId", String.valueOf(r.getDepositId()));
				else
					unit.put("DepositId", "");
				unit.put("Amount", String.valueOf(r.getAmount()));
				unit.put("RefundStatus", String.valueOf(r.getRefundStatus()));
				dataDeposit.add(unit);
			}
			
			allObjectTables.get("Deposit").setItems(dataDeposit);
	}
	public void updateBikeTable(List<Bike> rsBike) {
			ObservableList<Map<String, String>> dataBike = FXCollections.observableArrayList();
			for (Bike r : rsBike) {
				Map<String, String> unit = new HashMap<String, String>();
				
				
				if (r.getBikeId() != null)
					unit.put("BikeId", String.valueOf(r.getBikeId()));
				else
					unit.put("BikeId", "");
				if (r.getLocation() != null)
					unit.put("Location", String.valueOf(r.getLocation()));
				else
					unit.put("Location", "");
				if (r.getStatus() != null)
					unit.put("Status", String.valueOf(r.getStatus()));
				else
					unit.put("Status", "");
				dataBike.add(unit);
			}
			
			allObjectTables.get("Bike").setItems(dataBike);
	}
	public void updateOrderTable(List<Order> rsOrder) {
			ObservableList<Map<String, String>> dataOrder = FXCollections.observableArrayList();
			for (Order r : rsOrder) {
				Map<String, String> unit = new HashMap<String, String>();
				
				
				if (r.getOrderId() != null)
					unit.put("OrderId", String.valueOf(r.getOrderId()));
				else
					unit.put("OrderId", "");
				if (r.getStartTime() != null)
					unit.put("StartTime", r.getStartTime().format(dateformatter));
				else
					unit.put("StartTime", "");
				if (r.getEndTime() != null)
					unit.put("EndTime", r.getEndTime().format(dateformatter));
				else
					unit.put("EndTime", "");
				unit.put("Distance", String.valueOf(r.getDistance()));
				dataOrder.add(unit);
			}
			
			allObjectTables.get("Order").setItems(dataOrder);
	}
	public void updateFaultReportTable(List<FaultReport> rsFaultReport) {
			ObservableList<Map<String, String>> dataFaultReport = FXCollections.observableArrayList();
			for (FaultReport r : rsFaultReport) {
				Map<String, String> unit = new HashMap<String, String>();
				
				
				if (r.getRepritId() != null)
					unit.put("RepritId", String.valueOf(r.getRepritId()));
				else
					unit.put("RepritId", "");
				if (r.getFaultType() != null)
					unit.put("FaultType", String.valueOf(r.getFaultType()));
				else
					unit.put("FaultType", "");
				if (r.getPhotos() != null)
					unit.put("Photos", String.valueOf(r.getPhotos()));
				else
					unit.put("Photos", "");
				dataFaultReport.add(unit);
			}
			
			allObjectTables.get("FaultReport").setItems(dataFaultReport);
	}
	public void updatePaymentMethodTable(List<PaymentMethod> rsPaymentMethod) {
			ObservableList<Map<String, String>> dataPaymentMethod = FXCollections.observableArrayList();
			for (PaymentMethod r : rsPaymentMethod) {
				Map<String, String> unit = new HashMap<String, String>();
				
				
				if (r.getPaymentId() != null)
					unit.put("PaymentId", String.valueOf(r.getPaymentId()));
				else
					unit.put("PaymentId", "");
				if (r.getPaymentType() != null)
					unit.put("PaymentType", String.valueOf(r.getPaymentType()));
				else
					unit.put("PaymentType", "");
				dataPaymentMethod.add(unit);
			}
			
			allObjectTables.get("PaymentMethod").setItems(dataPaymentMethod);
	}
	public void updateCouponTable(List<Coupon> rsCoupon) {
			ObservableList<Map<String, String>> dataCoupon = FXCollections.observableArrayList();
			for (Coupon r : rsCoupon) {
				Map<String, String> unit = new HashMap<String, String>();
				
				
				if (r.getCouponId() != null)
					unit.put("CouponId", String.valueOf(r.getCouponId()));
				else
					unit.put("CouponId", "");
				if (r.getCouponType() != null)
					unit.put("CouponType", String.valueOf(r.getCouponType()));
				else
					unit.put("CouponType", "");
				if (r.getValidPeriod() != null)
					unit.put("ValidPeriod", r.getValidPeriod().format(dateformatter));
				else
					unit.put("ValidPeriod", "");
				dataCoupon.add(unit);
			}
			
			allObjectTables.get("Coupon").setItems(dataCoupon);
	}
	public void updateGeoPointTable(List<GeoPoint> rsGeoPoint) {
			ObservableList<Map<String, String>> dataGeoPoint = FXCollections.observableArrayList();
			for (GeoPoint r : rsGeoPoint) {
				Map<String, String> unit = new HashMap<String, String>();
				
				
				if (r.getLatitude() != null)
					unit.put("Latitude", String.valueOf(r.getLatitude()));
				else
					unit.put("Latitude", "");
				if (r.getLongitude() != null)
					unit.put("Longitude", String.valueOf(r.getLongitude()));
				else
					unit.put("Longitude", "");
				dataGeoPoint.add(unit);
			}
			
			allObjectTables.get("GeoPoint").setItems(dataGeoPoint);
	}
	public void updateWeChatPaymentTable(List<WeChatPayment> rsWeChatPayment) {
			ObservableList<Map<String, String>> dataWeChatPayment = FXCollections.observableArrayList();
			for (WeChatPayment r : rsWeChatPayment) {
				Map<String, String> unit = new HashMap<String, String>();
				
				if (r.getPaymentId() != null)
					unit.put("PaymentId", String.valueOf(r.getPaymentId()));
				else
					unit.put("PaymentId", "");
				if (r.getPaymentType() != null)
					unit.put("PaymentType", String.valueOf(r.getPaymentType()));
				else
					unit.put("PaymentType", "");
				
				if (r.getOpenId() != null)
					unit.put("OpenId", String.valueOf(r.getOpenId()));
				else
					unit.put("OpenId", "");
				dataWeChatPayment.add(unit);
			}
			
			allObjectTables.get("WeChatPayment").setItems(dataWeChatPayment);
	}
	public void updateAlipayUserIdTable(List<AlipayUserId> rsAlipayUserId) {
			ObservableList<Map<String, String>> dataAlipayUserId = FXCollections.observableArrayList();
			for (AlipayUserId r : rsAlipayUserId) {
				Map<String, String> unit = new HashMap<String, String>();
				
				if (r.getPaymentId() != null)
					unit.put("PaymentId", String.valueOf(r.getPaymentId()));
				else
					unit.put("PaymentId", "");
				if (r.getPaymentType() != null)
					unit.put("PaymentType", String.valueOf(r.getPaymentType()));
				else
					unit.put("PaymentType", "");
				
				if (r.getAlipayUserId() != null)
					unit.put("AlipayUserId", String.valueOf(r.getAlipayUserId()));
				else
					unit.put("AlipayUserId", "");
				dataAlipayUserId.add(unit);
			}
			
			allObjectTables.get("AlipayUserId").setItems(dataAlipayUserId);
	}
	
	/* 
	* update all object tables
	*/ 
	public void updateUserTable() {
			ObservableList<Map<String, String>> dataUser = FXCollections.observableArrayList();
			List<User> rsUser = EntityManager.getAllInstancesOf("User");
			for (User r : rsUser) {
				Map<String, String> unit = new HashMap<String, String>();

				if (r.getDepositId() != null)
					unit.put("DepositId", String.valueOf(r.getDepositId()));
				else
					unit.put("DepositId", "");
				unit.put("Amount", String.valueOf(r.getAmount()));
				unit.put("RefundStatus", String.valueOf(r.getRefundStatus()));

				if (r.getUserId() != null)
					unit.put("UserId", String.valueOf(r.getUserId()));
				else
					unit.put("UserId", "");
				if (r.getUsername() != null)
					unit.put("Username", String.valueOf(r.getUsername()));
				else
					unit.put("Username", "");
				if (r.getPhoneNumber() != null)
					unit.put("PhoneNumber", String.valueOf(r.getPhoneNumber()));
				else
					unit.put("PhoneNumber", "");
				if (r.getBalance() != null)
					unit.put("Balance", String.valueOf(r.getBalance()));
				else
					unit.put("Balance", "");
				dataUser.add(unit);
			}
			
			allObjectTables.get("User").setItems(dataUser);
	}
	public void updateThirdPartyAccountTable() {
			ObservableList<Map<String, String>> dataThirdPartyAccount = FXCollections.observableArrayList();
			List<ThirdPartyAccount> rsThirdPartyAccount = EntityManager.getAllInstancesOf("ThirdPartyAccount");
			for (ThirdPartyAccount r : rsThirdPartyAccount) {
				Map<String, String> unit = new HashMap<String, String>();


				if (r.getAccountId() != null)
					unit.put("AccountId", String.valueOf(r.getAccountId()));
				else
					unit.put("AccountId", "");
				unit.put("BindingStatus", String.valueOf(r.getBindingStatus()));
				dataThirdPartyAccount.add(unit);
			}
			
			allObjectTables.get("ThirdPartyAccount").setItems(dataThirdPartyAccount);
	}
	public void updateDepositTable() {
			ObservableList<Map<String, String>> dataDeposit = FXCollections.observableArrayList();
			List<Deposit> rsDeposit = EntityManager.getAllInstancesOf("Deposit");
			for (Deposit r : rsDeposit) {
				Map<String, String> unit = new HashMap<String, String>();


				if (r.getDepositId() != null)
					unit.put("DepositId", String.valueOf(r.getDepositId()));
				else
					unit.put("DepositId", "");
				unit.put("Amount", String.valueOf(r.getAmount()));
				unit.put("RefundStatus", String.valueOf(r.getRefundStatus()));
				dataDeposit.add(unit);
			}
			
			allObjectTables.get("Deposit").setItems(dataDeposit);
	}
	public void updateBikeTable() {
			ObservableList<Map<String, String>> dataBike = FXCollections.observableArrayList();
			List<Bike> rsBike = EntityManager.getAllInstancesOf("Bike");
			for (Bike r : rsBike) {
				Map<String, String> unit = new HashMap<String, String>();


				if (r.getBikeId() != null)
					unit.put("BikeId", String.valueOf(r.getBikeId()));
				else
					unit.put("BikeId", "");
				if (r.getLocation() != null)
					unit.put("Location", String.valueOf(r.getLocation()));
				else
					unit.put("Location", "");
				if (r.getStatus() != null)
					unit.put("Status", String.valueOf(r.getStatus()));
				else
					unit.put("Status", "");
				dataBike.add(unit);
			}
			
			allObjectTables.get("Bike").setItems(dataBike);
	}
	public void updateOrderTable() {
			ObservableList<Map<String, String>> dataOrder = FXCollections.observableArrayList();
			List<Order> rsOrder = EntityManager.getAllInstancesOf("Order");
			for (Order r : rsOrder) {
				Map<String, String> unit = new HashMap<String, String>();


				if (r.getOrderId() != null)
					unit.put("OrderId", String.valueOf(r.getOrderId()));
				else
					unit.put("OrderId", "");
				if (r.getStartTime() != null)
					unit.put("StartTime", r.getStartTime().format(dateformatter));
				else
					unit.put("StartTime", "");
				if (r.getEndTime() != null)
					unit.put("EndTime", r.getEndTime().format(dateformatter));
				else
					unit.put("EndTime", "");
				unit.put("Distance", String.valueOf(r.getDistance()));
				dataOrder.add(unit);
			}
			
			allObjectTables.get("Order").setItems(dataOrder);
	}
	public void updateFaultReportTable() {
			ObservableList<Map<String, String>> dataFaultReport = FXCollections.observableArrayList();
			List<FaultReport> rsFaultReport = EntityManager.getAllInstancesOf("FaultReport");
			for (FaultReport r : rsFaultReport) {
				Map<String, String> unit = new HashMap<String, String>();


				if (r.getRepritId() != null)
					unit.put("RepritId", String.valueOf(r.getRepritId()));
				else
					unit.put("RepritId", "");
				if (r.getFaultType() != null)
					unit.put("FaultType", String.valueOf(r.getFaultType()));
				else
					unit.put("FaultType", "");
				if (r.getPhotos() != null)
					unit.put("Photos", String.valueOf(r.getPhotos()));
				else
					unit.put("Photos", "");
				dataFaultReport.add(unit);
			}
			
			allObjectTables.get("FaultReport").setItems(dataFaultReport);
	}
	public void updatePaymentMethodTable() {
			ObservableList<Map<String, String>> dataPaymentMethod = FXCollections.observableArrayList();
			List<PaymentMethod> rsPaymentMethod = EntityManager.getAllInstancesOf("PaymentMethod");
			for (PaymentMethod r : rsPaymentMethod) {
				Map<String, String> unit = new HashMap<String, String>();


				if (r.getPaymentId() != null)
					unit.put("PaymentId", String.valueOf(r.getPaymentId()));
				else
					unit.put("PaymentId", "");
				if (r.getPaymentType() != null)
					unit.put("PaymentType", String.valueOf(r.getPaymentType()));
				else
					unit.put("PaymentType", "");
				dataPaymentMethod.add(unit);
			}
			
			allObjectTables.get("PaymentMethod").setItems(dataPaymentMethod);
	}
	public void updateCouponTable() {
			ObservableList<Map<String, String>> dataCoupon = FXCollections.observableArrayList();
			List<Coupon> rsCoupon = EntityManager.getAllInstancesOf("Coupon");
			for (Coupon r : rsCoupon) {
				Map<String, String> unit = new HashMap<String, String>();


				if (r.getCouponId() != null)
					unit.put("CouponId", String.valueOf(r.getCouponId()));
				else
					unit.put("CouponId", "");
				if (r.getCouponType() != null)
					unit.put("CouponType", String.valueOf(r.getCouponType()));
				else
					unit.put("CouponType", "");
				if (r.getValidPeriod() != null)
					unit.put("ValidPeriod", r.getValidPeriod().format(dateformatter));
				else
					unit.put("ValidPeriod", "");
				dataCoupon.add(unit);
			}
			
			allObjectTables.get("Coupon").setItems(dataCoupon);
	}
	public void updateGeoPointTable() {
			ObservableList<Map<String, String>> dataGeoPoint = FXCollections.observableArrayList();
			List<GeoPoint> rsGeoPoint = EntityManager.getAllInstancesOf("GeoPoint");
			for (GeoPoint r : rsGeoPoint) {
				Map<String, String> unit = new HashMap<String, String>();


				if (r.getLatitude() != null)
					unit.put("Latitude", String.valueOf(r.getLatitude()));
				else
					unit.put("Latitude", "");
				if (r.getLongitude() != null)
					unit.put("Longitude", String.valueOf(r.getLongitude()));
				else
					unit.put("Longitude", "");
				dataGeoPoint.add(unit);
			}
			
			allObjectTables.get("GeoPoint").setItems(dataGeoPoint);
	}
	public void updateWeChatPaymentTable() {
			ObservableList<Map<String, String>> dataWeChatPayment = FXCollections.observableArrayList();
			List<WeChatPayment> rsWeChatPayment = EntityManager.getAllInstancesOf("WeChatPayment");
			for (WeChatPayment r : rsWeChatPayment) {
				Map<String, String> unit = new HashMap<String, String>();

				if (r.getPaymentId() != null)
					unit.put("PaymentId", String.valueOf(r.getPaymentId()));
				else
					unit.put("PaymentId", "");
				if (r.getPaymentType() != null)
					unit.put("PaymentType", String.valueOf(r.getPaymentType()));
				else
					unit.put("PaymentType", "");

				if (r.getOpenId() != null)
					unit.put("OpenId", String.valueOf(r.getOpenId()));
				else
					unit.put("OpenId", "");
				dataWeChatPayment.add(unit);
			}
			
			allObjectTables.get("WeChatPayment").setItems(dataWeChatPayment);
	}
	public void updateAlipayUserIdTable() {
			ObservableList<Map<String, String>> dataAlipayUserId = FXCollections.observableArrayList();
			List<AlipayUserId> rsAlipayUserId = EntityManager.getAllInstancesOf("AlipayUserId");
			for (AlipayUserId r : rsAlipayUserId) {
				Map<String, String> unit = new HashMap<String, String>();

				if (r.getPaymentId() != null)
					unit.put("PaymentId", String.valueOf(r.getPaymentId()));
				else
					unit.put("PaymentId", "");
				if (r.getPaymentType() != null)
					unit.put("PaymentType", String.valueOf(r.getPaymentType()));
				else
					unit.put("PaymentType", "");

				if (r.getAlipayUserId() != null)
					unit.put("AlipayUserId", String.valueOf(r.getAlipayUserId()));
				else
					unit.put("AlipayUserId", "");
				dataAlipayUserId.add(unit);
			}
			
			allObjectTables.get("AlipayUserId").setItems(dataAlipayUserId);
	}
	
	public void classStatisicBingding() {
	
		 classInfodata = FXCollections.observableArrayList();
	 	 user = new ClassInfo("User", EntityManager.getAllInstancesOf("User").size());
	 	 classInfodata.add(user);
	 	 thirdpartyaccount = new ClassInfo("ThirdPartyAccount", EntityManager.getAllInstancesOf("ThirdPartyAccount").size());
	 	 classInfodata.add(thirdpartyaccount);
	 	 deposit = new ClassInfo("Deposit", EntityManager.getAllInstancesOf("Deposit").size());
	 	 classInfodata.add(deposit);
	 	 bike = new ClassInfo("Bike", EntityManager.getAllInstancesOf("Bike").size());
	 	 classInfodata.add(bike);
	 	 order = new ClassInfo("Order", EntityManager.getAllInstancesOf("Order").size());
	 	 classInfodata.add(order);
	 	 faultreport = new ClassInfo("FaultReport", EntityManager.getAllInstancesOf("FaultReport").size());
	 	 classInfodata.add(faultreport);
	 	 paymentmethod = new ClassInfo("PaymentMethod", EntityManager.getAllInstancesOf("PaymentMethod").size());
	 	 classInfodata.add(paymentmethod);
	 	 coupon = new ClassInfo("Coupon", EntityManager.getAllInstancesOf("Coupon").size());
	 	 classInfodata.add(coupon);
	 	 geopoint = new ClassInfo("GeoPoint", EntityManager.getAllInstancesOf("GeoPoint").size());
	 	 classInfodata.add(geopoint);
	 	 wechatpayment = new ClassInfo("WeChatPayment", EntityManager.getAllInstancesOf("WeChatPayment").size());
	 	 classInfodata.add(wechatpayment);
	 	 alipayuserid = new ClassInfo("AlipayUserId", EntityManager.getAllInstancesOf("AlipayUserId").size());
	 	 classInfodata.add(alipayuserid);
	 	 
		 class_statisic.setItems(classInfodata);
		 
		 //Class Statisic Binding
		 class_statisic.getSelectionModel().selectedItemProperty().addListener(
				 (observable, oldValue, newValue) ->  { 
				 										 //no selected object in table
				 										 objectindex = -1;
				 										 
				 										 //get lastest data, reflect updateTableData method
				 										 try {
												 			 Method updateob = this.getClass().getMethod("update" + newValue.getName() + "Table", null);
												 			 updateob.invoke(this);			 
												 		 } catch (Exception e) {
												 		 	 e.printStackTrace();
												 		 }		 										 
				 	
				 										 //show object table
				 			 				 			 TableView obs = allObjectTables.get(newValue.getName());
				 			 				 			 if (obs != null) {
				 			 				 				object_statics.setContent(obs);
				 			 				 				object_statics.setText("All Objects " + newValue.getName() + ":");
				 			 				 			 }
				 			 				 			 
				 			 				 			 //update association information
							 			 				 updateAssociation(newValue.getName());
				 			 				 			 
				 			 				 			 //show association information
				 			 				 			 ObservableList<AssociationInfo> asso = allassociationData.get(newValue.getName());
				 			 				 			 if (asso != null) {
				 			 				 			 	association_statisic.setItems(asso);
				 			 				 			 }
				 			 				 		  });
	}
	
	public void classStatisticUpdate() {
	 	 user.setNumber(EntityManager.getAllInstancesOf("User").size());
	 	 thirdpartyaccount.setNumber(EntityManager.getAllInstancesOf("ThirdPartyAccount").size());
	 	 deposit.setNumber(EntityManager.getAllInstancesOf("Deposit").size());
	 	 bike.setNumber(EntityManager.getAllInstancesOf("Bike").size());
	 	 order.setNumber(EntityManager.getAllInstancesOf("Order").size());
	 	 faultreport.setNumber(EntityManager.getAllInstancesOf("FaultReport").size());
	 	 paymentmethod.setNumber(EntityManager.getAllInstancesOf("PaymentMethod").size());
	 	 coupon.setNumber(EntityManager.getAllInstancesOf("Coupon").size());
	 	 geopoint.setNumber(EntityManager.getAllInstancesOf("GeoPoint").size());
	 	 wechatpayment.setNumber(EntityManager.getAllInstancesOf("WeChatPayment").size());
	 	 alipayuserid.setNumber(EntityManager.getAllInstancesOf("AlipayUserId").size());
		
	}
	
	/**
	 * association binding
	 */
	public void associationStatisicBingding() {
		
		allassociationData = new HashMap<String, ObservableList<AssociationInfo>>();
		
		ObservableList<AssociationInfo> User_association_data = FXCollections.observableArrayList();
		AssociationInfo User_associatition_UsertoThirdPartyAccount = new AssociationInfo("User", "ThirdPartyAccount", "UsertoThirdPartyAccount", false);
		User_association_data.add(User_associatition_UsertoThirdPartyAccount);
		AssociationInfo User_associatition_UsertoBike = new AssociationInfo("User", "Bike", "UsertoBike", false);
		User_association_data.add(User_associatition_UsertoBike);
		AssociationInfo User_associatition_UsertoOrder = new AssociationInfo("User", "Order", "UsertoOrder", false);
		User_association_data.add(User_associatition_UsertoOrder);
		AssociationInfo User_associatition_UsertoFaultReport = new AssociationInfo("User", "FaultReport", "UsertoFaultReport", false);
		User_association_data.add(User_associatition_UsertoFaultReport);
		
		allassociationData.put("User", User_association_data);
		
		ObservableList<AssociationInfo> ThirdPartyAccount_association_data = FXCollections.observableArrayList();
		
		allassociationData.put("ThirdPartyAccount", ThirdPartyAccount_association_data);
		
		ObservableList<AssociationInfo> Deposit_association_data = FXCollections.observableArrayList();
		AssociationInfo Deposit_associatition_DeposittoOrder = new AssociationInfo("Deposit", "Order", "DeposittoOrder", false);
		Deposit_association_data.add(Deposit_associatition_DeposittoOrder);
		
		allassociationData.put("Deposit", Deposit_association_data);
		
		ObservableList<AssociationInfo> Bike_association_data = FXCollections.observableArrayList();
		AssociationInfo Bike_associatition_BiketoOrder = new AssociationInfo("Bike", "Order", "BiketoOrder", false);
		Bike_association_data.add(Bike_associatition_BiketoOrder);
		AssociationInfo Bike_associatition_BiketoFaultReport = new AssociationInfo("Bike", "FaultReport", "BiketoFaultReport", false);
		Bike_association_data.add(Bike_associatition_BiketoFaultReport);
		AssociationInfo Bike_associatition_BiketoGeoPoint = new AssociationInfo("Bike", "GeoPoint", "BiketoGeoPoint", false);
		Bike_association_data.add(Bike_associatition_BiketoGeoPoint);
		
		allassociationData.put("Bike", Bike_association_data);
		
		ObservableList<AssociationInfo> Order_association_data = FXCollections.observableArrayList();
		AssociationInfo Order_associatition_OrdertoCoupon = new AssociationInfo("Order", "Coupon", "OrdertoCoupon", false);
		Order_association_data.add(Order_associatition_OrdertoCoupon);
		AssociationInfo Order_associatition_OrdertoPaymentMethod = new AssociationInfo("Order", "PaymentMethod", "OrdertoPaymentMethod", false);
		Order_association_data.add(Order_associatition_OrdertoPaymentMethod);
		
		allassociationData.put("Order", Order_association_data);
		
		ObservableList<AssociationInfo> FaultReport_association_data = FXCollections.observableArrayList();
		AssociationInfo FaultReport_associatition_FaultReporttoGeoPoint = new AssociationInfo("FaultReport", "GeoPoint", "FaultReporttoGeoPoint", false);
		FaultReport_association_data.add(FaultReport_associatition_FaultReporttoGeoPoint);
		
		allassociationData.put("FaultReport", FaultReport_association_data);
		
		ObservableList<AssociationInfo> PaymentMethod_association_data = FXCollections.observableArrayList();
		
		allassociationData.put("PaymentMethod", PaymentMethod_association_data);
		
		ObservableList<AssociationInfo> Coupon_association_data = FXCollections.observableArrayList();
		
		allassociationData.put("Coupon", Coupon_association_data);
		
		ObservableList<AssociationInfo> GeoPoint_association_data = FXCollections.observableArrayList();
		
		allassociationData.put("GeoPoint", GeoPoint_association_data);
		
		ObservableList<AssociationInfo> WeChatPayment_association_data = FXCollections.observableArrayList();
		
		allassociationData.put("WeChatPayment", WeChatPayment_association_data);
		
		ObservableList<AssociationInfo> AlipayUserId_association_data = FXCollections.observableArrayList();
		
		allassociationData.put("AlipayUserId", AlipayUserId_association_data);
		
		
		association_statisic.getSelectionModel().selectedItemProperty().addListener(
			    (observable, oldValue, newValue) ->  { 
	
							 		if (newValue != null) {
							 			 try {
							 			 	 if (newValue.getNumber() != 0) {
								 				 //choose object or not
								 				 if (objectindex != -1) {
									 				 Class[] cArg = new Class[1];
									 				 cArg[0] = List.class;
									 				 //reflect updateTableData method
										 			 Method updateob = this.getClass().getMethod("update" + newValue.getTargetClass() + "Table", cArg);
										 			 //find choosen object
										 			 Object selectedob = EntityManager.getAllInstancesOf(newValue.getSourceClass()).get(objectindex);
										 			 //reflect find association method
										 			 Method getAssociatedObject = selectedob.getClass().getMethod("get" + newValue.getAssociationName());
										 			 List r = new LinkedList();
										 			 //one or mulity?
										 			 if (newValue.getIsMultiple() == true) {
											 			 
											 			r = (List) getAssociatedObject.invoke(selectedob);
										 			 }
										 			 else {
										 				r.add(getAssociatedObject.invoke(selectedob));
										 			 }
										 			 //invoke update method
										 			 updateob.invoke(this, r);
										 			  
										 			 
								 				 }
												 //bind updated data to GUI
					 				 			 TableView obs = allObjectTables.get(newValue.getTargetClass());
					 				 			 if (obs != null) {
					 				 				object_statics.setContent(obs);
					 				 				object_statics.setText("Targets Objects " + newValue.getTargetClass() + ":");
					 				 			 }
					 				 		 }
							 			 }
							 			 catch (Exception e) {
							 				 e.printStackTrace();
							 			 }
							 		}
					 		  });
		
	}	
	
	

    //prepare data for contract
	public void prepareData() {
		
		//definition map
		definitions_map = new HashMap<String, String>();
		definitions_map.put("checkPhoneValidity", "validPattern:String = '^1[3-9]\\\\d{9}$'\r\r\n");
		
		//precondition map
		preconditions_map = new HashMap<String, String>();
		preconditions_map.put("checkPhoneValidity", "true");
		preconditions_map.put("createAccount", "// checkPhoneValidity(phoneNumber) // \u4F9D\u8D56\u6821\u9A8C\u5408\u7EA6  \ntrue");
		preconditions_map.put("issueNewcomerCoupons", "// targetUser.oclIsUndefined() = false\ntrue");
		preconditions_map.put("establishBluetoothConnection", "// targetBike.oclIsUndefined() = false and\n// targetBike.status = \"AVAILABLE\"\ntrue");
		preconditions_map.put("sendUnlockCommand", "// targetBike.bluetoothConnected = \ntrue");
		preconditions_map.put("playUnlockSuccessVoice", "// targetBike.status = \"IN_USE\"\ntrue");
		preconditions_map.put("calculateFare", "// rideDuration > 0\ntrue");
		preconditions_map.put("updateFareSuspensionWindow", "true");
		preconditions_map.put("sendFareEstimationNotification", "true");
		preconditions_map.put("getVehicleLocation", "true");
		preconditions_map.put("cacheReportData", "// isWeakNetwork\ntrue");
		preconditions_map.put("submitRepairWorkOrder", "// NetworkChecker.checkSignalStrength() >= 1 and  \n// cachedData.oclIsUndefined() = false\ntrue");
		
		//postcondition map
		postconditions_map = new HashMap<String, String>();
		postconditions_map.put("checkPhoneValidity", "true");
		postconditions_map.put("createAccount", "// newUser.phoneNumber = phoneNumber and\n// newUser.registrationTime = now() and\n// newUser.balance = 0.0 and\nresult = true");
		postconditions_map.put("issueNewcomerCoupons", "// targetUser.coupons->includes(newCoupon) and\n// newCoupon.status = \"UNUSED\" and\nresult = true");
		postconditions_map.put("establishBluetoothConnection", "// targetBike.bluetoothConnected = true and\n// targetBike.lastConnectionTime = now() and\nresult = true");
		postconditions_map.put("sendUnlockCommand", "// targetBike.status = \"IN_USE\" and\n// targetBike.unlockTime = now() and\nresult = true");
		postconditions_map.put("playUnlockSuccessVoice", "true");
		postconditions_map.put("calculateFare", "// result = timeFee + distanceFee and\nresult >= 1");
		postconditions_map.put("updateFareSuspensionWindow", "// userSession.displayedFare = currentFare and\n// userSession.fareUpdateTime = now() and\nresult = true");
		postconditions_map.put("sendFareEstimationNotification", "result = true");
		postconditions_map.put("getVehicleLocation", "result.latitude <> 0 and\nresult.longitude <> 0\n");
		postconditions_map.put("cacheReportData", "result = true");
		postconditions_map.put("submitRepairWorkOrder", "result = true");
		
		//service invariants map
		service_invariants_map = new LinkedHashMap<String, String>();
		
		//entity invariants map
		entity_invariants_map = new LinkedHashMap<String, String>();
		
	}
	
	public void generatOperationPane() {
		
		 operationPanels = new LinkedHashMap<String, GridPane>();
		
		 // ==================== GridPane_checkPhoneValidity ====================
		 GridPane checkPhoneValidity = new GridPane();
		 checkPhoneValidity.setHgap(4);
		 checkPhoneValidity.setVgap(6);
		 checkPhoneValidity.setPadding(new Insets(8, 8, 8, 8));
		 
		 ObservableList<Node> checkPhoneValidity_content = checkPhoneValidity.getChildren();
		 Label checkPhoneValidity_phoneNumber_label = new Label("phoneNumber:");
		 checkPhoneValidity_phoneNumber_label.setMinWidth(Region.USE_PREF_SIZE);
		 checkPhoneValidity_content.add(checkPhoneValidity_phoneNumber_label);
		 GridPane.setConstraints(checkPhoneValidity_phoneNumber_label, 0, 0);
		 
		 checkPhoneValidity_phoneNumber_t = new TextField();
		 checkPhoneValidity_content.add(checkPhoneValidity_phoneNumber_t);
		 checkPhoneValidity_phoneNumber_t.setMinWidth(Region.USE_PREF_SIZE);
		 GridPane.setConstraints(checkPhoneValidity_phoneNumber_t, 1, 0);
		 operationPanels.put("checkPhoneValidity", checkPhoneValidity);
		 
		 // ==================== GridPane_createAccount ====================
		 GridPane createAccount = new GridPane();
		 createAccount.setHgap(4);
		 createAccount.setVgap(6);
		 createAccount.setPadding(new Insets(8, 8, 8, 8));
		 
		 ObservableList<Node> createAccount_content = createAccount.getChildren();
		 Label createAccount_phoneNumber_label = new Label("phoneNumber:");
		 createAccount_phoneNumber_label.setMinWidth(Region.USE_PREF_SIZE);
		 createAccount_content.add(createAccount_phoneNumber_label);
		 GridPane.setConstraints(createAccount_phoneNumber_label, 0, 0);
		 
		 createAccount_phoneNumber_t = new TextField();
		 createAccount_content.add(createAccount_phoneNumber_t);
		 createAccount_phoneNumber_t.setMinWidth(Region.USE_PREF_SIZE);
		 GridPane.setConstraints(createAccount_phoneNumber_t, 1, 0);
		 operationPanels.put("createAccount", createAccount);
		 
		 // ==================== GridPane_issueNewcomerCoupons ====================
		 GridPane issueNewcomerCoupons = new GridPane();
		 issueNewcomerCoupons.setHgap(4);
		 issueNewcomerCoupons.setVgap(6);
		 issueNewcomerCoupons.setPadding(new Insets(8, 8, 8, 8));
		 
		 ObservableList<Node> issueNewcomerCoupons_content = issueNewcomerCoupons.getChildren();
		 Label issueNewcomerCoupons_userId_label = new Label("userId:");
		 issueNewcomerCoupons_userId_label.setMinWidth(Region.USE_PREF_SIZE);
		 issueNewcomerCoupons_content.add(issueNewcomerCoupons_userId_label);
		 GridPane.setConstraints(issueNewcomerCoupons_userId_label, 0, 0);
		 
		 issueNewcomerCoupons_userId_t = new TextField();
		 issueNewcomerCoupons_content.add(issueNewcomerCoupons_userId_t);
		 issueNewcomerCoupons_userId_t.setMinWidth(Region.USE_PREF_SIZE);
		 GridPane.setConstraints(issueNewcomerCoupons_userId_t, 1, 0);
		 operationPanels.put("issueNewcomerCoupons", issueNewcomerCoupons);
		 
		 // ==================== GridPane_establishBluetoothConnection ====================
		 GridPane establishBluetoothConnection = new GridPane();
		 establishBluetoothConnection.setHgap(4);
		 establishBluetoothConnection.setVgap(6);
		 establishBluetoothConnection.setPadding(new Insets(8, 8, 8, 8));
		 
		 ObservableList<Node> establishBluetoothConnection_content = establishBluetoothConnection.getChildren();
		 Label establishBluetoothConnection_qrCode_label = new Label("qrCode:");
		 establishBluetoothConnection_qrCode_label.setMinWidth(Region.USE_PREF_SIZE);
		 establishBluetoothConnection_content.add(establishBluetoothConnection_qrCode_label);
		 GridPane.setConstraints(establishBluetoothConnection_qrCode_label, 0, 0);
		 
		 establishBluetoothConnection_qrCode_t = new TextField();
		 establishBluetoothConnection_content.add(establishBluetoothConnection_qrCode_t);
		 establishBluetoothConnection_qrCode_t.setMinWidth(Region.USE_PREF_SIZE);
		 GridPane.setConstraints(establishBluetoothConnection_qrCode_t, 1, 0);
		 operationPanels.put("establishBluetoothConnection", establishBluetoothConnection);
		 
		 // ==================== GridPane_sendUnlockCommand ====================
		 GridPane sendUnlockCommand = new GridPane();
		 sendUnlockCommand.setHgap(4);
		 sendUnlockCommand.setVgap(6);
		 sendUnlockCommand.setPadding(new Insets(8, 8, 8, 8));
		 
		 ObservableList<Node> sendUnlockCommand_content = sendUnlockCommand.getChildren();
		 Label sendUnlockCommand_bikeId_label = new Label("bikeId:");
		 sendUnlockCommand_bikeId_label.setMinWidth(Region.USE_PREF_SIZE);
		 sendUnlockCommand_content.add(sendUnlockCommand_bikeId_label);
		 GridPane.setConstraints(sendUnlockCommand_bikeId_label, 0, 0);
		 
		 sendUnlockCommand_bikeId_t = new TextField();
		 sendUnlockCommand_content.add(sendUnlockCommand_bikeId_t);
		 sendUnlockCommand_bikeId_t.setMinWidth(Region.USE_PREF_SIZE);
		 GridPane.setConstraints(sendUnlockCommand_bikeId_t, 1, 0);
		 operationPanels.put("sendUnlockCommand", sendUnlockCommand);
		 
		 // ==================== GridPane_playUnlockSuccessVoice ====================
		 GridPane playUnlockSuccessVoice = new GridPane();
		 playUnlockSuccessVoice.setHgap(4);
		 playUnlockSuccessVoice.setVgap(6);
		 playUnlockSuccessVoice.setPadding(new Insets(8, 8, 8, 8));
		 
		 ObservableList<Node> playUnlockSuccessVoice_content = playUnlockSuccessVoice.getChildren();
		 Label playUnlockSuccessVoice_bikeId_label = new Label("bikeId:");
		 playUnlockSuccessVoice_bikeId_label.setMinWidth(Region.USE_PREF_SIZE);
		 playUnlockSuccessVoice_content.add(playUnlockSuccessVoice_bikeId_label);
		 GridPane.setConstraints(playUnlockSuccessVoice_bikeId_label, 0, 0);
		 
		 playUnlockSuccessVoice_bikeId_t = new TextField();
		 playUnlockSuccessVoice_content.add(playUnlockSuccessVoice_bikeId_t);
		 playUnlockSuccessVoice_bikeId_t.setMinWidth(Region.USE_PREF_SIZE);
		 GridPane.setConstraints(playUnlockSuccessVoice_bikeId_t, 1, 0);
		 operationPanels.put("playUnlockSuccessVoice", playUnlockSuccessVoice);
		 
		 // ==================== GridPane_calculateFare ====================
		 GridPane calculateFare = new GridPane();
		 calculateFare.setHgap(4);
		 calculateFare.setVgap(6);
		 calculateFare.setPadding(new Insets(8, 8, 8, 8));
		 
		 ObservableList<Node> calculateFare_content = calculateFare.getChildren();
		 Label calculateFare_bikeId_label = new Label("bikeId:");
		 calculateFare_bikeId_label.setMinWidth(Region.USE_PREF_SIZE);
		 calculateFare_content.add(calculateFare_bikeId_label);
		 GridPane.setConstraints(calculateFare_bikeId_label, 0, 0);
		 
		 calculateFare_bikeId_t = new TextField();
		 calculateFare_content.add(calculateFare_bikeId_t);
		 calculateFare_bikeId_t.setMinWidth(Region.USE_PREF_SIZE);
		 GridPane.setConstraints(calculateFare_bikeId_t, 1, 0);
		 Label calculateFare_rideDuration_label = new Label("rideDuration:");
		 calculateFare_rideDuration_label.setMinWidth(Region.USE_PREF_SIZE);
		 calculateFare_content.add(calculateFare_rideDuration_label);
		 GridPane.setConstraints(calculateFare_rideDuration_label, 0, 1);
		 
		 calculateFare_rideDuration_t = new TextField();
		 calculateFare_content.add(calculateFare_rideDuration_t);
		 calculateFare_rideDuration_t.setMinWidth(Region.USE_PREF_SIZE);
		 GridPane.setConstraints(calculateFare_rideDuration_t, 1, 1);
		 operationPanels.put("calculateFare", calculateFare);
		 
		 // ==================== GridPane_updateFareSuspensionWindow ====================
		 GridPane updateFareSuspensionWindow = new GridPane();
		 updateFareSuspensionWindow.setHgap(4);
		 updateFareSuspensionWindow.setVgap(6);
		 updateFareSuspensionWindow.setPadding(new Insets(8, 8, 8, 8));
		 
		 ObservableList<Node> updateFareSuspensionWindow_content = updateFareSuspensionWindow.getChildren();
		 Label updateFareSuspensionWindow_userId_label = new Label("userId:");
		 updateFareSuspensionWindow_userId_label.setMinWidth(Region.USE_PREF_SIZE);
		 updateFareSuspensionWindow_content.add(updateFareSuspensionWindow_userId_label);
		 GridPane.setConstraints(updateFareSuspensionWindow_userId_label, 0, 0);
		 
		 updateFareSuspensionWindow_userId_t = new TextField();
		 updateFareSuspensionWindow_content.add(updateFareSuspensionWindow_userId_t);
		 updateFareSuspensionWindow_userId_t.setMinWidth(Region.USE_PREF_SIZE);
		 GridPane.setConstraints(updateFareSuspensionWindow_userId_t, 1, 0);
		 Label updateFareSuspensionWindow_currentFare_label = new Label("currentFare:");
		 updateFareSuspensionWindow_currentFare_label.setMinWidth(Region.USE_PREF_SIZE);
		 updateFareSuspensionWindow_content.add(updateFareSuspensionWindow_currentFare_label);
		 GridPane.setConstraints(updateFareSuspensionWindow_currentFare_label, 0, 1);
		 
		 updateFareSuspensionWindow_currentFare_t = new TextField();
		 updateFareSuspensionWindow_content.add(updateFareSuspensionWindow_currentFare_t);
		 updateFareSuspensionWindow_currentFare_t.setMinWidth(Region.USE_PREF_SIZE);
		 GridPane.setConstraints(updateFareSuspensionWindow_currentFare_t, 1, 1);
		 operationPanels.put("updateFareSuspensionWindow", updateFareSuspensionWindow);
		 
		 // ==================== GridPane_sendFareEstimationNotification ====================
		 GridPane sendFareEstimationNotification = new GridPane();
		 sendFareEstimationNotification.setHgap(4);
		 sendFareEstimationNotification.setVgap(6);
		 sendFareEstimationNotification.setPadding(new Insets(8, 8, 8, 8));
		 
		 ObservableList<Node> sendFareEstimationNotification_content = sendFareEstimationNotification.getChildren();
		 Label sendFareEstimationNotification_userId_label = new Label("userId:");
		 sendFareEstimationNotification_userId_label.setMinWidth(Region.USE_PREF_SIZE);
		 sendFareEstimationNotification_content.add(sendFareEstimationNotification_userId_label);
		 GridPane.setConstraints(sendFareEstimationNotification_userId_label, 0, 0);
		 
		 sendFareEstimationNotification_userId_t = new TextField();
		 sendFareEstimationNotification_content.add(sendFareEstimationNotification_userId_t);
		 sendFareEstimationNotification_userId_t.setMinWidth(Region.USE_PREF_SIZE);
		 GridPane.setConstraints(sendFareEstimationNotification_userId_t, 1, 0);
		 operationPanels.put("sendFareEstimationNotification", sendFareEstimationNotification);
		 
		 // ==================== GridPane_getVehicleLocation ====================
		 GridPane getVehicleLocation = new GridPane();
		 getVehicleLocation.setHgap(4);
		 getVehicleLocation.setVgap(6);
		 getVehicleLocation.setPadding(new Insets(8, 8, 8, 8));
		 
		 ObservableList<Node> getVehicleLocation_content = getVehicleLocation.getChildren();
		 Label getVehicleLocation_bikeId_label = new Label("bikeId:");
		 getVehicleLocation_bikeId_label.setMinWidth(Region.USE_PREF_SIZE);
		 getVehicleLocation_content.add(getVehicleLocation_bikeId_label);
		 GridPane.setConstraints(getVehicleLocation_bikeId_label, 0, 0);
		 
		 getVehicleLocation_bikeId_t = new TextField();
		 getVehicleLocation_content.add(getVehicleLocation_bikeId_t);
		 getVehicleLocation_bikeId_t.setMinWidth(Region.USE_PREF_SIZE);
		 GridPane.setConstraints(getVehicleLocation_bikeId_t, 1, 0);
		 operationPanels.put("getVehicleLocation", getVehicleLocation);
		 
		 // ==================== GridPane_cacheReportData ====================
		 GridPane cacheReportData = new GridPane();
		 cacheReportData.setHgap(4);
		 cacheReportData.setVgap(6);
		 cacheReportData.setPadding(new Insets(8, 8, 8, 8));
		 
		 ObservableList<Node> cacheReportData_content = cacheReportData.getChildren();
		 Label cacheReportData_bikeId_label = new Label("bikeId:");
		 cacheReportData_bikeId_label.setMinWidth(Region.USE_PREF_SIZE);
		 cacheReportData_content.add(cacheReportData_bikeId_label);
		 GridPane.setConstraints(cacheReportData_bikeId_label, 0, 0);
		 
		 cacheReportData_bikeId_t = new TextField();
		 cacheReportData_content.add(cacheReportData_bikeId_t);
		 cacheReportData_bikeId_t.setMinWidth(Region.USE_PREF_SIZE);
		 GridPane.setConstraints(cacheReportData_bikeId_t, 1, 0);
		 Label cacheReportData_faultDescription_label = new Label("faultDescription:");
		 cacheReportData_faultDescription_label.setMinWidth(Region.USE_PREF_SIZE);
		 cacheReportData_content.add(cacheReportData_faultDescription_label);
		 GridPane.setConstraints(cacheReportData_faultDescription_label, 0, 1);
		 
		 cacheReportData_faultDescription_t = new TextField();
		 cacheReportData_content.add(cacheReportData_faultDescription_t);
		 cacheReportData_faultDescription_t.setMinWidth(Region.USE_PREF_SIZE);
		 GridPane.setConstraints(cacheReportData_faultDescription_t, 1, 1);
		 operationPanels.put("cacheReportData", cacheReportData);
		 
		 // ==================== GridPane_submitRepairWorkOrder ====================
		 GridPane submitRepairWorkOrder = new GridPane();
		 submitRepairWorkOrder.setHgap(4);
		 submitRepairWorkOrder.setVgap(6);
		 submitRepairWorkOrder.setPadding(new Insets(8, 8, 8, 8));
		 
		 ObservableList<Node> submitRepairWorkOrder_content = submitRepairWorkOrder.getChildren();
		 Label submitRepairWorkOrder_bikeId_label = new Label("bikeId:");
		 submitRepairWorkOrder_bikeId_label.setMinWidth(Region.USE_PREF_SIZE);
		 submitRepairWorkOrder_content.add(submitRepairWorkOrder_bikeId_label);
		 GridPane.setConstraints(submitRepairWorkOrder_bikeId_label, 0, 0);
		 
		 submitRepairWorkOrder_bikeId_t = new TextField();
		 submitRepairWorkOrder_content.add(submitRepairWorkOrder_bikeId_t);
		 submitRepairWorkOrder_bikeId_t.setMinWidth(Region.USE_PREF_SIZE);
		 GridPane.setConstraints(submitRepairWorkOrder_bikeId_t, 1, 0);
		 operationPanels.put("submitRepairWorkOrder", submitRepairWorkOrder);
		 
	}	

	public void actorTreeViewBinding() {
		
		 

		TreeItem<String> treeRootadministrator = new TreeItem<String>("Root node");
		
		TreeItem<String> subTreeRoot_User = new TreeItem<String>("manageUser");
					 		subTreeRoot_User.getChildren().addAll(Arrays.asList(					 		
					 			 		new TreeItem<String>("createUser"),
					 			 		new TreeItem<String>("queryUser"),
					 			 		new TreeItem<String>("modifyUser"),
					 			 		new TreeItem<String>("deleteUser")					 			 	
					 			 	));							 		
		
					 			
						 		
		treeRootadministrator.getChildren().addAll(Arrays.asList(
		 	subTreeRoot_User
				));	
				
	 			treeRootadministrator.setExpanded(true);

		actor_treeview_administrator.setShowRoot(false);
		actor_treeview_administrator.setRoot(treeRootadministrator);
	 		
		actor_treeview_administrator.getSelectionModel().selectedItemProperty().addListener(
		 				 (observable, oldValue, newValue) -> { 
		 				 								
		 				 							 //clear the previous return
		 											 operation_return_pane.setContent(new Label());
		 											 
		 				 							 clickedOp = newValue.getValue();
		 				 							 GridPane op = operationPanels.get(clickedOp);
		 				 							 VBox vb = opInvariantPanel.get(clickedOp);
		 				 							 
		 				 							 //op pannel
		 				 							 if (op != null) {
		 				 								 operation_paras.setContent(operationPanels.get(newValue.getValue()));
		 				 								 
		 				 								 ObservableList<Node> l = operationPanels.get(newValue.getValue()).getChildren();
		 				 								 choosenOperation = new LinkedList<TextField>();
		 				 								 for (Node n : l) {
		 				 								 	 if (n instanceof TextField) {
		 				 								 	 	choosenOperation.add((TextField)n);
		 				 								 	  }
		 				 								 }
		 				 								 
		 				 								 definition.setText(definitions_map.get(newValue.getValue()));
		 				 								 precondition.setText(preconditions_map.get(newValue.getValue()));
		 				 								 postcondition.setText(postconditions_map.get(newValue.getValue()));
		 				 								 
		 				 						     }
		 				 							 else {
		 				 								 Label l = new Label(newValue.getValue() + " is no contract information in requirement model.");
		 				 								 l.setPadding(new Insets(8, 8, 8, 8));
		 				 								 operation_paras.setContent(l);
		 				 							 }	
		 				 							 
		 				 							 //op invariants
		 				 							 if (vb != null) {
		 				 							 	ScrollPane scrollPane = new ScrollPane(vb);
		 				 							 	scrollPane.setFitToWidth(true);
		 				 							 	invariants_panes.setMaxHeight(200); 
		 				 							 	//all_invariant_pane.setContent(scrollPane);	
		 				 							 	
		 				 							 	invariants_panes.setContent(scrollPane);
		 				 							 } else {
		 				 							 	 Label l = new Label(newValue.getValue() + " is no related invariants");
		 				 							     l.setPadding(new Insets(8, 8, 8, 8));
		 				 							     invariants_panes.setContent(l);
		 				 							 }
		 				 							 
		 				 							 //reset pre- and post-conditions area color
		 				 							 precondition.setStyle("-fx-background-color:#FFFFFF; -fx-control-inner-background: #FFFFFF ");
		 				 							 postcondition.setStyle("-fx-background-color:#FFFFFF; -fx-control-inner-background: #FFFFFF");
		 				 							 //reset condition panel title
		 				 							 precondition_pane.setText("Precondition");
		 				 							 postcondition_pane.setText("Postcondition");
		 				 						} 
		 				 				);

		
		
		 
		TreeItem<String> treeRootuser = new TreeItem<String>("Root node");
			TreeItem<String> subTreeRoot_registerAccount = new TreeItem<String>("registerAccount");
			subTreeRoot_registerAccount.getChildren().addAll(Arrays.asList(			 		    
					 	new TreeItem<String>("checkPhoneValidity"),
					 	new TreeItem<String>("createAccount"),
					 	new TreeItem<String>("issueNewcomerCoupons")
				 		));	
			TreeItem<String> subTreeRoot_unlockVehicle = new TreeItem<String>("unlockVehicle");
			subTreeRoot_unlockVehicle.getChildren().addAll(Arrays.asList(			 		    
					 	new TreeItem<String>("establishBluetoothConnection"),
					 	new TreeItem<String>("sendUnlockCommand"),
					 	new TreeItem<String>("playUnlockSuccessVoice")
				 		));	
			TreeItem<String> subTreeRoot_trackRidingCosts = new TreeItem<String>("trackRidingCosts");
			subTreeRoot_trackRidingCosts.getChildren().addAll(Arrays.asList(			 		    
					 	new TreeItem<String>("calculateFare"),
					 	new TreeItem<String>("updateFareSuspensionWindow"),
					 	new TreeItem<String>("sendFareEstimationNotification")
				 		));	
		
		treeRootuser.getChildren().addAll(Arrays.asList(
			subTreeRoot_registerAccount,
			subTreeRoot_unlockVehicle,
			subTreeRoot_trackRidingCosts
					));
		
		treeRootuser.setExpanded(true);

		actor_treeview_user.setShowRoot(false);
		actor_treeview_user.setRoot(treeRootuser);
		
		//TreeView click, then open the GridPane for inputing parameters
		actor_treeview_user.getSelectionModel().selectedItemProperty().addListener(
						 (observable, oldValue, newValue) -> { 
						 								
						 							 //clear the previous return
													 operation_return_pane.setContent(new Label());
													 
						 							 clickedOp = newValue.getValue();
						 							 GridPane op = operationPanels.get(clickedOp);
						 							 VBox vb = opInvariantPanel.get(clickedOp);
						 							 
						 							 //op pannel
						 							 if (op != null) {
						 								 operation_paras.setContent(operationPanels.get(newValue.getValue()));
						 								 
						 								 ObservableList<Node> l = operationPanels.get(newValue.getValue()).getChildren();
						 								 choosenOperation = new LinkedList<TextField>();
						 								 for (Node n : l) {
						 								 	 if (n instanceof TextField) {
						 								 	 	choosenOperation.add((TextField)n);
						 								 	  }
						 								 }
						 								 
						 								 definition.setText(definitions_map.get(newValue.getValue()));
						 								 precondition.setText(preconditions_map.get(newValue.getValue()));
						 								 postcondition.setText(postconditions_map.get(newValue.getValue()));
						 								 
						 						     }
						 							 else {
						 								 Label l = new Label(newValue.getValue() + " is no contract information in requirement model.");
						 								 l.setPadding(new Insets(8, 8, 8, 8));
						 								 operation_paras.setContent(l);
						 							 }	
						 							 
						 							 //op invariants
						 							 if (vb != null) {
						 							 	ScrollPane scrollPane = new ScrollPane(vb);
						 							 	scrollPane.setFitToWidth(true);
						 							 	invariants_panes.setMaxHeight(200); 
						 							 	//all_invariant_pane.setContent(scrollPane);	
						 							 	
						 							 	invariants_panes.setContent(scrollPane);
						 							 } else {
						 							 	 Label l = new Label(newValue.getValue() + " is no related invariants");
						 							     l.setPadding(new Insets(8, 8, 8, 8));
						 							     invariants_panes.setContent(l);
						 							 }
						 							 
						 							 //reset pre- and post-conditions area color
						 							 precondition.setStyle("-fx-background-color:#FFFFFF; -fx-control-inner-background: #FFFFFF ");
						 							 postcondition.setStyle("-fx-background-color:#FFFFFF; -fx-control-inner-background: #FFFFFF");
						 							 //reset condition panel title
						 							 precondition_pane.setText("Precondition");
						 							 postcondition_pane.setText("Postcondition");
						 						} 
						 				);
		TreeItem<String> treeRootsystemadministrator = new TreeItem<String>("Root node");
			TreeItem<String> subTreeRoot_processMaintenanceRequests = new TreeItem<String>("processMaintenanceRequests");
			subTreeRoot_processMaintenanceRequests.getChildren().addAll(Arrays.asList(			 		    
					 	new TreeItem<String>("getVehicleLocation"),
					 	new TreeItem<String>("cacheReportData"),
					 	new TreeItem<String>("submitRepairWorkOrder")
				 		));	
		
		treeRootsystemadministrator.getChildren().addAll(Arrays.asList(
			new TreeItem<String>("manageVehicleFleet"),
			subTreeRoot_processMaintenanceRequests
					));
		
		treeRootsystemadministrator.setExpanded(true);

		actor_treeview_systemadministrator.setShowRoot(false);
		actor_treeview_systemadministrator.setRoot(treeRootsystemadministrator);
		
		//TreeView click, then open the GridPane for inputing parameters
		actor_treeview_systemadministrator.getSelectionModel().selectedItemProperty().addListener(
						 (observable, oldValue, newValue) -> { 
						 								
						 							 //clear the previous return
													 operation_return_pane.setContent(new Label());
													 
						 							 clickedOp = newValue.getValue();
						 							 GridPane op = operationPanels.get(clickedOp);
						 							 VBox vb = opInvariantPanel.get(clickedOp);
						 							 
						 							 //op pannel
						 							 if (op != null) {
						 								 operation_paras.setContent(operationPanels.get(newValue.getValue()));
						 								 
						 								 ObservableList<Node> l = operationPanels.get(newValue.getValue()).getChildren();
						 								 choosenOperation = new LinkedList<TextField>();
						 								 for (Node n : l) {
						 								 	 if (n instanceof TextField) {
						 								 	 	choosenOperation.add((TextField)n);
						 								 	  }
						 								 }
						 								 
						 								 definition.setText(definitions_map.get(newValue.getValue()));
						 								 precondition.setText(preconditions_map.get(newValue.getValue()));
						 								 postcondition.setText(postconditions_map.get(newValue.getValue()));
						 								 
						 						     }
						 							 else {
						 								 Label l = new Label(newValue.getValue() + " is no contract information in requirement model.");
						 								 l.setPadding(new Insets(8, 8, 8, 8));
						 								 operation_paras.setContent(l);
						 							 }	
						 							 
						 							 //op invariants
						 							 if (vb != null) {
						 							 	ScrollPane scrollPane = new ScrollPane(vb);
						 							 	scrollPane.setFitToWidth(true);
						 							 	invariants_panes.setMaxHeight(200); 
						 							 	//all_invariant_pane.setContent(scrollPane);	
						 							 	
						 							 	invariants_panes.setContent(scrollPane);
						 							 } else {
						 							 	 Label l = new Label(newValue.getValue() + " is no related invariants");
						 							     l.setPadding(new Insets(8, 8, 8, 8));
						 							     invariants_panes.setContent(l);
						 							 }
						 							 
						 							 //reset pre- and post-conditions area color
						 							 precondition.setStyle("-fx-background-color:#FFFFFF; -fx-control-inner-background: #FFFFFF ");
						 							 postcondition.setStyle("-fx-background-color:#FFFFFF; -fx-control-inner-background: #FFFFFF");
						 							 //reset condition panel title
						 							 precondition_pane.setText("Precondition");
						 							 postcondition_pane.setText("Postcondition");
						 						} 
						 				);
	}

	/**
	*    Execute Operation
	*/
	@FXML
	public void execute(ActionEvent event) {
		
		switch (clickedOp) {
		case "checkPhoneValidity" : checkPhoneValidity(); break;
		case "createAccount" : createAccount(); break;
		case "issueNewcomerCoupons" : issueNewcomerCoupons(); break;
		case "establishBluetoothConnection" : establishBluetoothConnection(); break;
		case "sendUnlockCommand" : sendUnlockCommand(); break;
		case "playUnlockSuccessVoice" : playUnlockSuccessVoice(); break;
		case "calculateFare" : calculateFare(); break;
		case "updateFareSuspensionWindow" : updateFareSuspensionWindow(); break;
		case "sendFareEstimationNotification" : sendFareEstimationNotification(); break;
		case "getVehicleLocation" : getVehicleLocation(); break;
		case "cacheReportData" : cacheReportData(); break;
		case "submitRepairWorkOrder" : submitRepairWorkOrder(); break;
		
		}
		
		System.out.println("execute buttion clicked");
		
		//checking relevant invariants
		opInvairantPanelUpdate();
	}

	/**
	*    Refresh All
	*/		
	@FXML
	public void refresh(ActionEvent event) {
		
		refreshAll();
		System.out.println("refresh all");
	}		
	
	/**
	*    Save All
	*/			
	@FXML
	public void save(ActionEvent event) {
		
		Stage stage = (Stage) mainPane.getScene().getWindow();
		
		FileChooser fileChooser = new FileChooser();
		fileChooser.setTitle("Save State to File");
		fileChooser.setInitialFileName("*.state");
		fileChooser.getExtensionFilters().addAll(
		         new ExtensionFilter("RMCode State File", "*.state"));
		
		File file = fileChooser.showSaveDialog(stage);
		
		if (file != null) {
			System.out.println("save state to file " + file.getAbsolutePath());				
			EntityManager.save(file);
		}
	}
	
	/**
	*    Load All
	*/			
	@FXML
	public void load(ActionEvent event) {
		
		Stage stage = (Stage) mainPane.getScene().getWindow();
		
		FileChooser fileChooser = new FileChooser();
		fileChooser.setTitle("Open State File");
		fileChooser.getExtensionFilters().addAll(
		         new ExtensionFilter("RMCode State File", "*.state"));
		
		File file = fileChooser.showOpenDialog(stage);
		
		if (file != null) {
			System.out.println("choose file" + file.getAbsolutePath());
			EntityManager.load(file); 
		}
		
		//refresh GUI after load data
		refreshAll();
	}
	
	
	//precondition unsat dialog
	public void preconditionUnSat() {
		
		Alert alert = new Alert(AlertType.WARNING, "");
        alert.initModality(Modality.APPLICATION_MODAL);
        alert.initOwner(mainPane.getScene().getWindow());
        alert.getDialogPane().setContentText("Precondtion is not satisfied");
        alert.getDialogPane().setHeaderText(null);
        alert.showAndWait();	
	}
	
	//postcondition unsat dialog
	public void postconditionUnSat() {
		
		Alert alert = new Alert(AlertType.WARNING, "");
        alert.initModality(Modality.APPLICATION_MODAL);
        alert.initOwner(mainPane.getScene().getWindow());
        alert.getDialogPane().setContentText("Postcondtion is not satisfied");
        alert.getDialogPane().setHeaderText(null);
        alert.showAndWait();	
	}

	public void thirdpartyServiceUnSat() {
		
		Alert alert = new Alert(AlertType.WARNING, "");
        alert.initModality(Modality.APPLICATION_MODAL);
        alert.initOwner(mainPane.getScene().getWindow());
        alert.getDialogPane().setContentText("third party service is exception");
        alert.getDialogPane().setHeaderText(null);
        alert.showAndWait();	
	}		
	
	
	public void checkPhoneValidity() {
		
		System.out.println("execute checkPhoneValidity");
		String time = String.format("%1$tH:%1$tM:%1$tS", System.currentTimeMillis());
		log.appendText(time + " -- execute operation: checkPhoneValidity in service: RegisterAccountService ");
		
		try {
			//invoke op with parameters
			//return value is primitive type, bind result to label.
			String result = String.valueOf(registeraccountservice_service.checkPhoneValidity(
			checkPhoneValidity_phoneNumber_t.getText()
			));	
			Label l = new Label(result);
			l.setPadding(new Insets(8, 8, 8, 8));
			operation_return_pane.setContent(l);
		    log.appendText(" -- success!\n");
		    //set pre- and post-conditions text area color
		    precondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #7CFC00");
		    postcondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #7CFC00");
		    //contract evaluation result
		    precondition_pane.setText("Precondition: True");
		    postcondition_pane.setText("Postcondition: True");
		    
		    
		} catch (PreconditionException e) {
			log.appendText(" -- failed!\n");
			precondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #FF0000");
			precondition_pane.setText("Precondition: False");	
			preconditionUnSat();
			
		} catch (PostconditionException e) {
			log.appendText(" -- failed!\n");
			postcondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #FF0000");	
			postcondition_pane.setText("Postcondition: False");
			postconditionUnSat();
			
		} catch (NumberFormatException e) {
			log.appendText(" -- failed!\n");
			precondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #FF0000");
			precondition_pane.setText("Precondition: False");	
			preconditionUnSat();
			
		} catch (Exception e ) {		
			if (e instanceof ThirdPartyServiceException)
				thirdpartyServiceUnSat();
		}
	}
	public void createAccount() {
		
		System.out.println("execute createAccount");
		String time = String.format("%1$tH:%1$tM:%1$tS", System.currentTimeMillis());
		log.appendText(time + " -- execute operation: createAccount in service: RegisterAccountService ");
		
		try {
			//invoke op with parameters
			//return value is primitive type, bind result to label.
			String result = String.valueOf(registeraccountservice_service.createAccount(
			createAccount_phoneNumber_t.getText()
			));	
			Label l = new Label(result);
			l.setPadding(new Insets(8, 8, 8, 8));
			operation_return_pane.setContent(l);
		    log.appendText(" -- success!\n");
		    //set pre- and post-conditions text area color
		    precondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #7CFC00");
		    postcondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #7CFC00");
		    //contract evaluation result
		    precondition_pane.setText("Precondition: True");
		    postcondition_pane.setText("Postcondition: True");
		    
		    
		} catch (PreconditionException e) {
			log.appendText(" -- failed!\n");
			precondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #FF0000");
			precondition_pane.setText("Precondition: False");	
			preconditionUnSat();
			
		} catch (PostconditionException e) {
			log.appendText(" -- failed!\n");
			postcondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #FF0000");	
			postcondition_pane.setText("Postcondition: False");
			postconditionUnSat();
			
		} catch (NumberFormatException e) {
			log.appendText(" -- failed!\n");
			precondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #FF0000");
			precondition_pane.setText("Precondition: False");	
			preconditionUnSat();
			
		} catch (Exception e ) {		
			if (e instanceof ThirdPartyServiceException)
				thirdpartyServiceUnSat();
		}
	}
	public void issueNewcomerCoupons() {
		
		System.out.println("execute issueNewcomerCoupons");
		String time = String.format("%1$tH:%1$tM:%1$tS", System.currentTimeMillis());
		log.appendText(time + " -- execute operation: issueNewcomerCoupons in service: RegisterAccountService ");
		
		try {
			//invoke op with parameters
			//return value is primitive type, bind result to label.
			String result = String.valueOf(registeraccountservice_service.issueNewcomerCoupons(
			issueNewcomerCoupons_userId_t.getText()
			));	
			Label l = new Label(result);
			l.setPadding(new Insets(8, 8, 8, 8));
			operation_return_pane.setContent(l);
		    log.appendText(" -- success!\n");
		    //set pre- and post-conditions text area color
		    precondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #7CFC00");
		    postcondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #7CFC00");
		    //contract evaluation result
		    precondition_pane.setText("Precondition: True");
		    postcondition_pane.setText("Postcondition: True");
		    
		    
		} catch (PreconditionException e) {
			log.appendText(" -- failed!\n");
			precondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #FF0000");
			precondition_pane.setText("Precondition: False");	
			preconditionUnSat();
			
		} catch (PostconditionException e) {
			log.appendText(" -- failed!\n");
			postcondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #FF0000");	
			postcondition_pane.setText("Postcondition: False");
			postconditionUnSat();
			
		} catch (NumberFormatException e) {
			log.appendText(" -- failed!\n");
			precondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #FF0000");
			precondition_pane.setText("Precondition: False");	
			preconditionUnSat();
			
		} catch (Exception e ) {		
			if (e instanceof ThirdPartyServiceException)
				thirdpartyServiceUnSat();
		}
	}
	public void establishBluetoothConnection() {
		
		System.out.println("execute establishBluetoothConnection");
		String time = String.format("%1$tH:%1$tM:%1$tS", System.currentTimeMillis());
		log.appendText(time + " -- execute operation: establishBluetoothConnection in service: UnlockVehicleService ");
		
		try {
			//invoke op with parameters
			//return value is primitive type, bind result to label.
			String result = String.valueOf(unlockvehicleservice_service.establishBluetoothConnection(
			establishBluetoothConnection_qrCode_t.getText()
			));	
			Label l = new Label(result);
			l.setPadding(new Insets(8, 8, 8, 8));
			operation_return_pane.setContent(l);
		    log.appendText(" -- success!\n");
		    //set pre- and post-conditions text area color
		    precondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #7CFC00");
		    postcondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #7CFC00");
		    //contract evaluation result
		    precondition_pane.setText("Precondition: True");
		    postcondition_pane.setText("Postcondition: True");
		    
		    
		} catch (PreconditionException e) {
			log.appendText(" -- failed!\n");
			precondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #FF0000");
			precondition_pane.setText("Precondition: False");	
			preconditionUnSat();
			
		} catch (PostconditionException e) {
			log.appendText(" -- failed!\n");
			postcondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #FF0000");	
			postcondition_pane.setText("Postcondition: False");
			postconditionUnSat();
			
		} catch (NumberFormatException e) {
			log.appendText(" -- failed!\n");
			precondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #FF0000");
			precondition_pane.setText("Precondition: False");	
			preconditionUnSat();
			
		} catch (Exception e ) {		
			if (e instanceof ThirdPartyServiceException)
				thirdpartyServiceUnSat();
		}
	}
	public void sendUnlockCommand() {
		
		System.out.println("execute sendUnlockCommand");
		String time = String.format("%1$tH:%1$tM:%1$tS", System.currentTimeMillis());
		log.appendText(time + " -- execute operation: sendUnlockCommand in service: UnlockVehicleService ");
		
		try {
			//invoke op with parameters
			//return value is primitive type, bind result to label.
			String result = String.valueOf(unlockvehicleservice_service.sendUnlockCommand(
			sendUnlockCommand_bikeId_t.getText()
			));	
			Label l = new Label(result);
			l.setPadding(new Insets(8, 8, 8, 8));
			operation_return_pane.setContent(l);
		    log.appendText(" -- success!\n");
		    //set pre- and post-conditions text area color
		    precondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #7CFC00");
		    postcondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #7CFC00");
		    //contract evaluation result
		    precondition_pane.setText("Precondition: True");
		    postcondition_pane.setText("Postcondition: True");
		    
		    
		} catch (PreconditionException e) {
			log.appendText(" -- failed!\n");
			precondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #FF0000");
			precondition_pane.setText("Precondition: False");	
			preconditionUnSat();
			
		} catch (PostconditionException e) {
			log.appendText(" -- failed!\n");
			postcondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #FF0000");	
			postcondition_pane.setText("Postcondition: False");
			postconditionUnSat();
			
		} catch (NumberFormatException e) {
			log.appendText(" -- failed!\n");
			precondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #FF0000");
			precondition_pane.setText("Precondition: False");	
			preconditionUnSat();
			
		} catch (Exception e ) {		
			if (e instanceof ThirdPartyServiceException)
				thirdpartyServiceUnSat();
		}
	}
	public void playUnlockSuccessVoice() {
		
		System.out.println("execute playUnlockSuccessVoice");
		String time = String.format("%1$tH:%1$tM:%1$tS", System.currentTimeMillis());
		log.appendText(time + " -- execute operation: playUnlockSuccessVoice in service: UnlockVehicleService ");
		
		try {
			//invoke op with parameters
			//return value is primitive type, bind result to label.
			String result = String.valueOf(unlockvehicleservice_service.playUnlockSuccessVoice(
			playUnlockSuccessVoice_bikeId_t.getText()
			));	
			Label l = new Label(result);
			l.setPadding(new Insets(8, 8, 8, 8));
			operation_return_pane.setContent(l);
		    log.appendText(" -- success!\n");
		    //set pre- and post-conditions text area color
		    precondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #7CFC00");
		    postcondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #7CFC00");
		    //contract evaluation result
		    precondition_pane.setText("Precondition: True");
		    postcondition_pane.setText("Postcondition: True");
		    
		    
		} catch (PreconditionException e) {
			log.appendText(" -- failed!\n");
			precondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #FF0000");
			precondition_pane.setText("Precondition: False");	
			preconditionUnSat();
			
		} catch (PostconditionException e) {
			log.appendText(" -- failed!\n");
			postcondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #FF0000");	
			postcondition_pane.setText("Postcondition: False");
			postconditionUnSat();
			
		} catch (NumberFormatException e) {
			log.appendText(" -- failed!\n");
			precondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #FF0000");
			precondition_pane.setText("Precondition: False");	
			preconditionUnSat();
			
		} catch (Exception e ) {		
			if (e instanceof ThirdPartyServiceException)
				thirdpartyServiceUnSat();
		}
	}
	public void calculateFare() {
		
		System.out.println("execute calculateFare");
		String time = String.format("%1$tH:%1$tM:%1$tS", System.currentTimeMillis());
		log.appendText(time + " -- execute operation: calculateFare in service: TrackRidingCostsService ");
		
		try {
			//invoke op with parameters
			//return value is primitive type, bind result to label.
			String result = String.valueOf(trackridingcostsservice_service.calculateFare(
			calculateFare_bikeId_t.getText(),
			Integer.valueOf(calculateFare_rideDuration_t.getText())
			));	
			Label l = new Label(result);
			l.setPadding(new Insets(8, 8, 8, 8));
			operation_return_pane.setContent(l);
		    log.appendText(" -- success!\n");
		    //set pre- and post-conditions text area color
		    precondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #7CFC00");
		    postcondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #7CFC00");
		    //contract evaluation result
		    precondition_pane.setText("Precondition: True");
		    postcondition_pane.setText("Postcondition: True");
		    
		    
		} catch (PreconditionException e) {
			log.appendText(" -- failed!\n");
			precondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #FF0000");
			precondition_pane.setText("Precondition: False");	
			preconditionUnSat();
			
		} catch (PostconditionException e) {
			log.appendText(" -- failed!\n");
			postcondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #FF0000");	
			postcondition_pane.setText("Postcondition: False");
			postconditionUnSat();
			
		} catch (NumberFormatException e) {
			log.appendText(" -- failed!\n");
			precondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #FF0000");
			precondition_pane.setText("Precondition: False");	
			preconditionUnSat();
			
		} catch (Exception e ) {		
			if (e instanceof ThirdPartyServiceException)
				thirdpartyServiceUnSat();
		}
	}
	public void updateFareSuspensionWindow() {
		
		System.out.println("execute updateFareSuspensionWindow");
		String time = String.format("%1$tH:%1$tM:%1$tS", System.currentTimeMillis());
		log.appendText(time + " -- execute operation: updateFareSuspensionWindow in service: TrackRidingCostsService ");
		
		try {
			//invoke op with parameters
			//return value is primitive type, bind result to label.
			String result = String.valueOf(trackridingcostsservice_service.updateFareSuspensionWindow(
			updateFareSuspensionWindow_userId_t.getText(),
			Integer.valueOf(updateFareSuspensionWindow_currentFare_t.getText())
			));	
			Label l = new Label(result);
			l.setPadding(new Insets(8, 8, 8, 8));
			operation_return_pane.setContent(l);
		    log.appendText(" -- success!\n");
		    //set pre- and post-conditions text area color
		    precondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #7CFC00");
		    postcondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #7CFC00");
		    //contract evaluation result
		    precondition_pane.setText("Precondition: True");
		    postcondition_pane.setText("Postcondition: True");
		    
		    
		} catch (PreconditionException e) {
			log.appendText(" -- failed!\n");
			precondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #FF0000");
			precondition_pane.setText("Precondition: False");	
			preconditionUnSat();
			
		} catch (PostconditionException e) {
			log.appendText(" -- failed!\n");
			postcondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #FF0000");	
			postcondition_pane.setText("Postcondition: False");
			postconditionUnSat();
			
		} catch (NumberFormatException e) {
			log.appendText(" -- failed!\n");
			precondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #FF0000");
			precondition_pane.setText("Precondition: False");	
			preconditionUnSat();
			
		} catch (Exception e ) {		
			if (e instanceof ThirdPartyServiceException)
				thirdpartyServiceUnSat();
		}
	}
	public void sendFareEstimationNotification() {
		
		System.out.println("execute sendFareEstimationNotification");
		String time = String.format("%1$tH:%1$tM:%1$tS", System.currentTimeMillis());
		log.appendText(time + " -- execute operation: sendFareEstimationNotification in service: TrackRidingCostsService ");
		
		try {
			//invoke op with parameters
			//return value is primitive type, bind result to label.
			String result = String.valueOf(trackridingcostsservice_service.sendFareEstimationNotification(
			sendFareEstimationNotification_userId_t.getText()
			));	
			Label l = new Label(result);
			l.setPadding(new Insets(8, 8, 8, 8));
			operation_return_pane.setContent(l);
		    log.appendText(" -- success!\n");
		    //set pre- and post-conditions text area color
		    precondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #7CFC00");
		    postcondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #7CFC00");
		    //contract evaluation result
		    precondition_pane.setText("Precondition: True");
		    postcondition_pane.setText("Postcondition: True");
		    
		    
		} catch (PreconditionException e) {
			log.appendText(" -- failed!\n");
			precondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #FF0000");
			precondition_pane.setText("Precondition: False");	
			preconditionUnSat();
			
		} catch (PostconditionException e) {
			log.appendText(" -- failed!\n");
			postcondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #FF0000");	
			postcondition_pane.setText("Postcondition: False");
			postconditionUnSat();
			
		} catch (NumberFormatException e) {
			log.appendText(" -- failed!\n");
			precondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #FF0000");
			precondition_pane.setText("Precondition: False");	
			preconditionUnSat();
			
		} catch (Exception e ) {		
			if (e instanceof ThirdPartyServiceException)
				thirdpartyServiceUnSat();
		}
	}
	public void getVehicleLocation() {
		
		System.out.println("execute getVehicleLocation");
		String time = String.format("%1$tH:%1$tM:%1$tS", System.currentTimeMillis());
		log.appendText(time + " -- execute operation: getVehicleLocation in service: ProcessMaintenanceRequestsService ");
		
		try {
			//invoke op with parameters
			//return value is primitive type, bind result to label.
			String result = String.valueOf(processmaintenancerequestsservice_service.getVehicleLocation(
			getVehicleLocation_bikeId_t.getText()
			));	
			Label l = new Label(result);
			l.setPadding(new Insets(8, 8, 8, 8));
			operation_return_pane.setContent(l);
		    log.appendText(" -- success!\n");
		    //set pre- and post-conditions text area color
		    precondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #7CFC00");
		    postcondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #7CFC00");
		    //contract evaluation result
		    precondition_pane.setText("Precondition: True");
		    postcondition_pane.setText("Postcondition: True");
		    
		    
		} catch (PreconditionException e) {
			log.appendText(" -- failed!\n");
			precondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #FF0000");
			precondition_pane.setText("Precondition: False");	
			preconditionUnSat();
			
		} catch (PostconditionException e) {
			log.appendText(" -- failed!\n");
			postcondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #FF0000");	
			postcondition_pane.setText("Postcondition: False");
			postconditionUnSat();
			
		} catch (NumberFormatException e) {
			log.appendText(" -- failed!\n");
			precondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #FF0000");
			precondition_pane.setText("Precondition: False");	
			preconditionUnSat();
			
		} catch (Exception e ) {		
			if (e instanceof ThirdPartyServiceException)
				thirdpartyServiceUnSat();
		}
	}
	public void cacheReportData() {
		
		System.out.println("execute cacheReportData");
		String time = String.format("%1$tH:%1$tM:%1$tS", System.currentTimeMillis());
		log.appendText(time + " -- execute operation: cacheReportData in service: ProcessMaintenanceRequestsService ");
		
		try {
			//invoke op with parameters
			//return value is primitive type, bind result to label.
			String result = String.valueOf(processmaintenancerequestsservice_service.cacheReportData(
			cacheReportData_bikeId_t.getText(),
			cacheReportData_faultDescription_t.getText()
			));	
			Label l = new Label(result);
			l.setPadding(new Insets(8, 8, 8, 8));
			operation_return_pane.setContent(l);
		    log.appendText(" -- success!\n");
		    //set pre- and post-conditions text area color
		    precondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #7CFC00");
		    postcondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #7CFC00");
		    //contract evaluation result
		    precondition_pane.setText("Precondition: True");
		    postcondition_pane.setText("Postcondition: True");
		    
		    
		} catch (PreconditionException e) {
			log.appendText(" -- failed!\n");
			precondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #FF0000");
			precondition_pane.setText("Precondition: False");	
			preconditionUnSat();
			
		} catch (PostconditionException e) {
			log.appendText(" -- failed!\n");
			postcondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #FF0000");	
			postcondition_pane.setText("Postcondition: False");
			postconditionUnSat();
			
		} catch (NumberFormatException e) {
			log.appendText(" -- failed!\n");
			precondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #FF0000");
			precondition_pane.setText("Precondition: False");	
			preconditionUnSat();
			
		} catch (Exception e ) {		
			if (e instanceof ThirdPartyServiceException)
				thirdpartyServiceUnSat();
		}
	}
	public void submitRepairWorkOrder() {
		
		System.out.println("execute submitRepairWorkOrder");
		String time = String.format("%1$tH:%1$tM:%1$tS", System.currentTimeMillis());
		log.appendText(time + " -- execute operation: submitRepairWorkOrder in service: ProcessMaintenanceRequestsService ");
		
		try {
			//invoke op with parameters
			//return value is primitive type, bind result to label.
			String result = String.valueOf(processmaintenancerequestsservice_service.submitRepairWorkOrder(
			submitRepairWorkOrder_bikeId_t.getText()
			));	
			Label l = new Label(result);
			l.setPadding(new Insets(8, 8, 8, 8));
			operation_return_pane.setContent(l);
		    log.appendText(" -- success!\n");
		    //set pre- and post-conditions text area color
		    precondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #7CFC00");
		    postcondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #7CFC00");
		    //contract evaluation result
		    precondition_pane.setText("Precondition: True");
		    postcondition_pane.setText("Postcondition: True");
		    
		    
		} catch (PreconditionException e) {
			log.appendText(" -- failed!\n");
			precondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #FF0000");
			precondition_pane.setText("Precondition: False");	
			preconditionUnSat();
			
		} catch (PostconditionException e) {
			log.appendText(" -- failed!\n");
			postcondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #FF0000");	
			postcondition_pane.setText("Postcondition: False");
			postconditionUnSat();
			
		} catch (NumberFormatException e) {
			log.appendText(" -- failed!\n");
			precondition.setStyle("-fx-background-color:#000000; -fx-control-inner-background: #FF0000");
			precondition_pane.setText("Precondition: False");	
			preconditionUnSat();
			
		} catch (Exception e ) {		
			if (e instanceof ThirdPartyServiceException)
				thirdpartyServiceUnSat();
		}
	}




	//select object index
	int objectindex;
	
	@FXML
	TabPane mainPane;

	@FXML
	TextArea log;
	
	@FXML
	TreeView<String> actor_treeview_user;
	@FXML
	TreeView<String> actor_treeview_systemadministrator;
	
	@FXML
	TreeView<String> actor_treeview_administrator;


	@FXML
	TextArea definition;
	@FXML
	TextArea precondition;
	@FXML
	TextArea postcondition;
	@FXML
	TextArea invariants;
	
	@FXML
	TitledPane precondition_pane;
	@FXML
	TitledPane postcondition_pane;
	
	//chosen operation textfields
	List<TextField> choosenOperation;
	String clickedOp;
		
	@FXML
	TableView<ClassInfo> class_statisic;
	@FXML
	TableView<AssociationInfo> association_statisic;
	
	Map<String, ObservableList<AssociationInfo>> allassociationData;
	ObservableList<ClassInfo> classInfodata;
	
	NewBikeSharingSystemSystem newbikesharingsystemsystem_service;
	ThirdPartyServices thirdpartyservices_service;
	RegisterAccountService registeraccountservice_service;
	UnlockVehicleService unlockvehicleservice_service;
	TrackRidingCostsService trackridingcostsservice_service;
	ProcessMaintenanceRequestsService processmaintenancerequestsservice_service;
	
	ClassInfo user;
	ClassInfo thirdpartyaccount;
	ClassInfo deposit;
	ClassInfo bike;
	ClassInfo order;
	ClassInfo faultreport;
	ClassInfo paymentmethod;
	ClassInfo coupon;
	ClassInfo geopoint;
	ClassInfo wechatpayment;
	ClassInfo alipayuserid;
		
	@FXML
	TitledPane object_statics;
	Map<String, TableView> allObjectTables;
	
	@FXML
	TitledPane operation_paras;
	
	@FXML
	TitledPane operation_return_pane;
	
	@FXML 
	TitledPane all_invariant_pane;
	
	@FXML
	TitledPane invariants_panes;
	
	Map<String, GridPane> operationPanels;
	Map<String, VBox> opInvariantPanel;
	
	//all textfiled or eumntity
	TextField checkPhoneValidity_phoneNumber_t;
	TextField createAccount_phoneNumber_t;
	TextField issueNewcomerCoupons_userId_t;
	TextField establishBluetoothConnection_qrCode_t;
	TextField sendUnlockCommand_bikeId_t;
	TextField playUnlockSuccessVoice_bikeId_t;
	TextField calculateFare_bikeId_t;
	TextField calculateFare_rideDuration_t;
	TextField updateFareSuspensionWindow_userId_t;
	TextField updateFareSuspensionWindow_currentFare_t;
	TextField sendFareEstimationNotification_userId_t;
	TextField getVehicleLocation_bikeId_t;
	TextField cacheReportData_bikeId_t;
	TextField cacheReportData_faultDescription_t;
	TextField submitRepairWorkOrder_bikeId_t;
	
	HashMap<String, String> definitions_map;
	HashMap<String, String> preconditions_map;
	HashMap<String, String> postconditions_map;
	HashMap<String, String> invariants_map;
	LinkedHashMap<String, String> service_invariants_map;
	LinkedHashMap<String, String> entity_invariants_map;
	LinkedHashMap<String, Label> service_invariants_label_map;
	LinkedHashMap<String, Label> entity_invariants_label_map;
	LinkedHashMap<String, Label> op_entity_invariants_label_map;
	LinkedHashMap<String, Label> op_service_invariants_label_map;
	

	
}
